SQL Server Mathematical Functions

Mathematical Functions

Mathematical functions are used to perform mathematical operations.

ROUND Function

ROUND function is used to round off the decimal values into specified digits.

SELECT ROUND(11.3425, 2)
Output:
11.3400

returns numeric value with rounded off to 2 digits.

SELECT ROUND(11.3457, 2)
Output:
11.3500
SELECT ROUND(11.3457, 1)
Output:
11.3000
SELECT ROUND(11.3457, 0)
Output:
11.0000
SELECT ROUND(11.3457, -1)
Output:
10.0000
SELECT ROUND(11.3457, -2)
Output:
0.00000

POWER Function

POWER function is used to calculate power to the specified value for numeric expression or value.

SELECT POWER(2, 5)
Output:
32

SQRT Function

SQRT function is used to calculate the square root of the specified numeric value.

SELECT SQRT(25)
Output:
5

RAND Function

RAND function is used to generate the random numerical number between 0 to 1.

SELECT RAND()
Output:
0.99059783387109

SIGN Function

SIGN function is used to identify specified value is positive, negative or zero.

SELECT SIGN(200)
Output:
1
SELECT SIGN(-200)
Output:
-1
SELECT SIGN(0)
Output:
0

EXP Function

EXP function is used to calculate exponential value for the specified value.

SELECT EXP()
Output:
2.71828182845905

LOG Function

LOG Function is used to calculate natural logarithm of the specified value.

SELECT LOG(1)
Output:
0

LOG10 Function

LOG10 Function is used to calculate base-10 logarithm of the specified value.

SELECT LOG10(10)
Output:
1

FLOOR Function

FLOOR function is used to return largest integer which is less than or equal to specified value.

SELECT FLOOR(11.234)
Output:
11

ABS Function

ABS function is used to return the absolute value.

SELECT ABS(11.234)
Output:
11.234

COS, SIN, COT, TAN, ACOS, ASIN, ATAN, DEGREES and RADIANS functions are also available in SQL Server.




Python installation

Privacy Policy  |  Copyrightcopyright symbol2020 - All Rights Reserved.  |  Contact us   |  Report website issues in Github   |  Facebook page   |  Google+ page

Email Facebook Google LinkedIn Twitter
^