Postgresql Mathematical Functions
From w3cyberlearnings
# | Function | Example | Result | Description |
---|---|---|---|---|
1 | abs(x) | abs(-17.4) | 17.4 | absolute value |
2 | cbrt(x) | cbrt(27.0) | 3 | cube root |
3 | ceil(x) | ceil(-42.8) | -42 | smallest integer not less than argument |
4 | ceiling(x) | ceiling(-95.3) | -95 | smallest integer not less than argument (alias for ceil) |
5 | degreesx() | degrees(0.5) | 28.6478897565412 | radians to degrees |
6 | div(y/x) | div(9,4) | 2 | integer quotient of y/x |
7 | exp(x) | exp(1.0) | 2.71828182845905 | exponential |
8 | floor(x) | floor(-42.8) | -43 | largest integer not greater than argument |
9 | ln(x) | ln(2.0) | 0.693147180559945 | natural logarithm |
10 | log(x) | log(100.0) | 2 | base 10 logarithm |
11 | mod(y,x) | mod(9,4) | 1 | remainder of y/x |
12 | pi() | pi() | 3.14159265358979 | "p" constant |
13 | power(a,b) | power(9.0, 3.0) | 729 | a raised to the power of b |
14 | radians(x) | radians(45.0) | 0.785398163397448 | degrees to radians |
15 | random() | random() | random value in the range 0.0 <= x < 1.0 | |
16 | round(x) | round(42.4) | 42 | round to nearest integer |
17 | setseed(x) | setseed(0.54823) | set seed for subsequent random() calls (value between -1.0 and 1.0, inclusive) | |
18 | sign(x) | sign(-8.4) | -1 | sign of the argument (-1, 0, +1) |
19 | sqrt(x) | sqrt(2.0) | 1.4142135623731 | square root |
20 | trunc(x) | trunc(42.8) | 42 | truncate toward zero |
21 | width_bucket(op numeric, b1 numeric, b2 numeric, count int) | width_bucket(5.35, 0.024, 10.06, 5) | 3 | return the bucket to which operand would be assigned in an equidepth histogram with count buckets, in the range b1 to b2 |
22 | acos(x) | acos(x) | inverse cosine of x | inverse cosine |
23 | asin(x) | asin(x) | inverse sine of x | inverse sine |
24 | atan(x) | atan(x) | inverse tangent of x | inverse tangent |
25 | atan2(y,x) | atan2(y,x) | inverse tangent of y/x | inverse tangent of y/x |
26 | cos(x) | cos(x) | consine of x | cosine |
27 | cot(x) | cot(x) | cotangent of x | cotangent |
28 | sin(x) | sine(x) | sine of x | sine |
29 | tan(x) | tan(x) | tangent of x | tangent |