ABS
Returns the absolute value of a numeric value.
Syntax
ABS( numeric_value )
Argument | Required/ Optional | Description |
---|
numeric_value | Required | Numeric datatype. Returns the absolute value of a number. You can enter any valid expression. |
Return Value
Positive numeric value. ABS returns the same datatype as the numeric value passed as an argument. If you pass a Double, it returns a Double. Likewise, if you pass an Integer, it returns an Integer.
NULL if you pass a null value to the function.
Example
The following expression returns the difference between two numbers as a positive value, regardless of which number is larger:
ABS( PRICE - COST )
PRICE | COST | RETURN VALUE |
---|
250 | 150 | 100 |
52 | 48 | 4 |
169.95 | 69.95 | 100 |
59.95 | NULL | NULL |
70 | 30 | 40 |
430 | 330 | 100 |
100 | 200 | 100 |