I l @ ve RuBoard |
PostgreSQL includes many functions that assist in performing numerical calculations. The following sections discuss the included numerical functions in PostgreSQL. ABSDescriptionThe ABS function returns the absolute value of a supplied number. Input ABS( num ) ExamplesABS(-7) 7 ABS(-7.234) 7.234 NotesThe ABS function's return value is the same data type that it is passed. ACOSDescriptionThe ACOS function returns an inverse cosine. Input ACOS( num ) ASINDescriptionThe ASIN function returns an inverse sine. Input ASIN( num ) ATANDescriptionThe ATAN function returns an inverse tangent. Input ATAN( num ) ATAN2DescriptionThe ATAN2 function returns an inverse tangent of y/x. Input ATAN2( x,y ) CBRTDescriptionThe CBRT function returns the cube root of the supplied number. Input CBRT( num ) ExampleCBRT(27) 3 CEILDescriptionThe CEIL function returns the smallest integer not less than the supplied value. Input CEIL( num ) ExampleCEIL(-22.2) -22 COSDescriptionThe COS function returns a cosine value. Input COS( num ) COTDescriptionThe COT function returns a cotangent value. Input COT( num ) DEGREESDescriptionThe DEGREES function converts from radians to degrees. Input DEGREES( num ) ExampleDEGREES(1) 90 EXPDescriptionThe EXP function performs an exponential calculation on the supplied value. Input EXP( num ) ExampleEXP(0) 1.0 FLOORDescriptionThe FLOOR function returns the largest integer not greater than the supplied value. Input FLOOR( num ) ExampleFLOOR(-22.2) -23 LNDescriptionThe LN function performs a natural logarithm on the supplied number. Input LN( num ) ExampleLN(100) 4.6051701860 LOGDescriptionThe LOG function performs a standard base-10 logarithm on the supplied value. Input LOG( num ) ExampleLOG(100) 2.0 PIDescriptionThe PI function returns the standard pi value. InputsNone. ExamplePI() 3.1459265358979 POW or POWERDescriptionThe POW function raises a number by the specified exponent. Inputs POW( num, exp ) num ”The number on which to perform the exponentiation. exp ”The power to which to raise the number. ExamplesPOW(2,2) 4.0 POW(2,3) 8.0 RADIANSDescriptionThe RADIANS function converts the supplied degrees to radian units. Input RADIANS( num ) ExampleRADIANS(90) 1 RANDOMDescriptionThe RANDOM function returns a pseudorandom number between 0.0 and 1.0. InputsNone. ExampleRANDOM() .654387 ROUNDDescriptionThe ROUND function rounds a number to the specified decimal places. Inputs ROUND( num, dec ) num ”The number to manipulate. dec ”An integer that represents the number of decimal places. ExamplesROUND(1.589, 1) 1.6 ROUND(1.589, 2) 1.59 SINDescriptionThe SIN function performs a sine function on the supplied value. InputSIN(num) SQRTDescriptionThe SQRT function returns the square root of the supplied value. Input SQRT( num ) ExampleSQRT(9) 3 TANDescriptionThe TAN function performs a tangent calculation on the supplied number. Input TAN( num ) TRUNCDescriptionThe TRUNC function truncates to the specified number of decimal places without rounding them out. InputsTRUNC( num [, dec ]) num ”The number on which to perform the truncate. dec ”The number of decimal places to leave remaining, if supplied; otherwise , truncate all decimal places. ExamplesTRUNC(1.589999, 2) 1.58 TRUNC(1.589999) 1 |
I l @ ve RuBoard |