MSDN Documentation SQL Functions Mathematical Functions

Mathematical Functions

FunctionPurposeSyntax
ABS()Returns absolute valueABS ( numeric_expression )
CEILING()Returns smallest integer greater than or equal to the numberCEILING ( numeric_expression )
FLOOR()Returns largest integer less than or equal to the numberFLOOR ( numeric_expression )
ROUND()Rounds a number to specified decimal placesROUND ( numeric_expression , length [ ,function ] )
POWER()Returns value raised to a specified powerPOWER ( numeric_expression , power_expression )
SQRT()Returns square rootSQRT ( numeric_expression )
LOG()Returns natural logarithmLOG ( numeric_expression )
LOG10()Returns base‑10 logarithmLOG10 ( numeric_expression )
EXP()Returns e raised to the power of the argumentEXP ( numeric_expression )
SIGN()Returns sign of the numberSIGN ( numeric_expression )
PI()Returns the constant πPI ()

Examples

SELECT ABS(-15) AS AbsoluteValue;   -- Returns 15
SELECT CEILING(22.3) AS CeilValue;   -- Returns 23
SELECT FLOOR(22.9) AS FloorValue;    -- Returns 22
SELECT ROUND(123.4567, 2) AS Rounded;-- Returns 123.46
SELECT POWER(2,8) AS PowerResult;    -- Returns 256
SELECT SQRT(144) AS SqrtResult;      -- Returns 12
SELECT LOG(10) AS NaturalLog;        -- Returns 2.302585...
SELECT LOG10(1000) AS Log10Result;   -- Returns 3
SELECT EXP(1) AS ExpResult;          -- Returns 2.71828...
SELECT SIGN(-8) AS SignResult;       -- Returns -1
SELECT PI() AS PiValue;              -- Returns 3.1415926535...