MSSQL SERVER 2005 Math functions
1. To find absolute value
ABS ()
Select Fweight-50,abs (FWeight-50), ABS ( -5.38) from T_person
2. Power
Power (x,y) is used to compute the Y-exponentiation of X
Select Fweight,power (fweight,-0.5), Power (fweight,2),
Power (fweight,3), Power (fweight,4) from T_person
Select Power (2,2)
3. Square root
SQRT ()
Select Fweight,sqrt (fweight) from T_person
4. Ask for random number
RAND () supports either parameters or no parameters
Select RAND ()
Select RAND (123)
5. Round to the largest integer
CEILING ()
Select Fname,fweight,ceiling (fweight), CEILING (fweight*-1) from T_person
6. Round to the smallest integer
FLOOR ()
Select Fname,fweight,floor (fweight), FLOOR (fweight*-1) from T_person
7. Rounding
ROUND ()
ROUND (M,d) m is the numeric value to be rounded, D is the precision of the calculation, that is, the number of decimal places retained when rounding
D to 0 means that decimal places are not preserved, and D is a negative value that is rounded in the integer portion.
Select Fname,fweight,round (fweight,1), ROUND (fweight*-1,0), ROUND (fweight,-1) from T_person
8. To find the sine value
SIN ()