SIGN()

Scalar. Determines whether a given value is positive or negative.

Syntax

SIGN( value )
Data Types

Return

value

Integer

Integer

Long

Float

Interval

Usage

SIGN() returns 1 if value is positive, -1 if it is negative, and 0 otherwise.

Example

The following example uses the SIGN function to compute an additional commission discount of $50 if there are more than 10,000 shares of a stock traded, $0 discount if there are exactly 10,000 shares traded, and adds $50 to commission if less than 10,000 shares are traded:

INSERT INTO OutStream
SELECT SIGN(10000-Trades.Quantity)*50 + Trades.Commission, 
            Trades.StockName
FROM Trades;