Arithmetic Functions : Define Function « Function « SQL / MySQL






Arithmetic Functions

       

ABS(x)                        Calculates the absolute value (nonnegative number).
ACOS(x), ASIN(x)              Calculates the arcsin and arccos.
ATAN(x), ATAN2(x, y)          Calculates the arctangent.
CEILING(x)                    Rounds up to the least integer greater than or equal to x.
COS(x)                        Calculates the cosine; x is given in radians.
COT(x)                        Calculates the cotangent.
DEGREES(x)                    Converts radians to degrees (multiplication by 180/pi).
EXP(x)                        Returns e^x.
FLOOR(x)                      Rounds down to the greatest integer less than or equal to x.
LOG(x)                        Returns the natural logarithm (i.e., to base e).
LOG10(x)                      Returns the logarithm to base 10.
MOD(x, y)                     Returns the mod function, equivalent to x % y.
PI( )                         Returns 3.1415927.
POW(x, y)                     Returns x^y.
POWER(x, y)                   Equivalent to POW(x, y).
RADIANS(x)                    Converts degrees into radians (multiplication by Pi/180).
RAND( )                       Returns a random number between 0.0 and 1.0.
RAND(n)                       Returns a reproducible (thus not quite random) number.
ROUND(x)                      Rounds to the nearest integer.
ROUND(x, y)                   Rounds to y decimal places.
SIGN(x)                       Returns -1, 0, or 1 depending on the sign of x.
SIN(x)                        Calculates the sine.
SQRT(x)                       Calculates the square root.
TAN(x)                        Calculates the tangent.
TRUNCATE(x)                   Removes digits after the decimal point.
TRUNCATE(x, y)                Retains y digits after the decimal point (thus TRUNCATE(1.236439, 2) returns 1.23).

   
    
    
    
    
    
    
  








Related examples in the same category

1.Define function in C and call by SQL
2.Comparison Functions,Tests, Branching
3.Calculating, Formatting, and Transformation Functions