In general Arithmetic will come under Mathematical functions of SQL Server. All these functions will return the same data type as that of the input value.
Different Arithmetic Functions that are available are:
1. ABS() : Returns the absolute or positive value of the specified numeric expression.
Example: Select ABS(5) AbsoluteValue, ABS(0) AbsoluteValue,ABS(-14) AbsoluteValue
Output :
2. CEILING() : Returns the immediate smallest integer that is greater than or equal to the number specified.
Example : Select CEILING(-5.6), CEILING(-0.89), CEILING(+5.6)
Output :
3. FLOOR() : Returns the immediate largest integer that is smaller than or equal to the number specified.
Example : Select FLOOR(-5.6), FLOOR(-0.89), FLOOR(+5.6)
Output :
4. POWER() : Returns the Power of the specified expression.
Example : Select POWER(2,5) AS '2^5', POWER(4,3) AS '4^3'
Output :
5. ROUND() : Returns a numeric value, rounded to the specified length or precision.
Example : SELECT ROUND(14.994, 2) Rounded_Twovalues, ROUND(15.9995, 3) Rounded_Threevalues
Output :
6. SIGN() : Returns the positive (+1), zero (0), or negative (-1) sign of the specified expression
Example : SELECT SIGN(14) Positive , SIGN(-15) Negative,SIGN(0) Zero
Output :
7. SQRT() : Returns the Square Root of the specified float value.
Example : SELECT SQRT(3) 'SQRT(3)',SQRT(4) 'SQRT(4)'
Output :
8. SQUARE() : Returns the square of the specified value.
Example : SELECT SQUARE(3) 'SQUARE(3)', SQUARE(4) 'SQUARE(4)'
Output :
9. RAND() : Returns Random float value between 0 and 1. NO random value will match with other value.
Example : SELECT RAND() 'RANDOM Value1',RAND() 'RANDOM Value2', RAND() 'RANDOM Value3'
Output :
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.