Labone
Labone
server
• To see all built-in mathematical function
• navigate on sql server and expand sql database folder-->expand your database--
>expand programmability-->expand functions--expand system functions and
Mathematical functions
• -- Absolut value of any negative number
• select abs(-101.5)
• --ceiling the next highest number
• select CEILING(15.2)
• -- the next lower number
• select FLOOR(1.5)
• --select power of any two number
• select power(2,3)
• -- square of any number
• select SQUARE(9)
• --select square root of any number
• select SQRT(80)
• --select any random number between 0&1
• select rand()
• --return always the same value of rand
• select rand(1)
• --select randum between 1&100
• select CEILING(RAND()*100)
print 10 different value between
1&100
• declare @count int
• set @count=1
• while (@count<=10)
• begin
• print floor(rand()*100)
• set @count=@count+1
• end
• --round to 2 places after(to the right) decimal ponit
• select ROUND (123.756,2)--returns 123.760
• --Trancate anything after 2 places,after(to the right) decimal point
• select ROUND (123.756,2,1)--return 123.750
• -- round to 1 place after (to right) the decimal point
• select ROUND123.756,1)--123.800
• --truncate anything after 1 place, after(to right)the decimal ponit
• select ROUND(123.756,1,1)--123.700
• --round the last 2 places, before the decimal point
• select ROUND (123.756,-2)--returns 100.000
• --round the last 1 places, before the decimal point
• select ROUND (123.756,-1)--returns 120.000
THANK YOU