Skip to content

MATHEMATICAL FUNCTIONS :

Mathematical functions in sql server like Abs,Ceiling,floor,power,square,sqrt and round functions

Abs() :

ABS(numeric_expression) stands for absolute and returns the absolute (positive) number.

1
select abs(-105.35) ---Returns 105.35 with out (-sign)

Ceiling() :

The CEILING(numeric_expression) function returns the smallest integer value that is larger than or equal to a number.

1
2
SELECT CEILING(15.2) ----Returns 16
SELECT CEILING(-15.2) --- Returns 15

Floor() :

The FLOOR(numeric_expression) function returns the Lagest integer value that is less than or equal to a number

1
2
SELECT Floor(15.2) ---- Returns 15
SELECT Floor(-15.2)---Return 16

Power() :

power(expression,power) returns the power value of the specified expression to the specified power.

1
select power(expression,power)
1
2
3
4
ex:
the following example caluculates '2 to the power of 3'

select power(2,3) -----returns 8

Square() :

The SQUARE() function returns the square of a number.

1
2
3
select square(number)

select square(6)-----returns 36

SQRT() :

SQRT() returns the square root of a given value

1
2
3
select sqrt(number)

select sqrt(16)-----Returns 4

ROUND() :

The ROUND() function rounds a number to a specified number of decimal places

1
2
3
4
5
6
7
ROUND(number, decimals, operation)

Parameter   Description
number      Required. The number to be rounded
decimals    Required. The number of decimal places to round number to
operation   Optional. If 0, it rounds the result to the number of decimal. If another value than 0, it 
             truncates the result to the number of decimals. Default value is 0