abs ( numeric_type )
→ numeric_type
绝对值
abs(-17.4)
→ 17.4
|
cbrt ( double precision )
→ double precision
立方根
cbrt(64.0)
→ 4
|
ceil ( numeric )
→ numeric
ceil ( double precision )
→ double precision
大于或等于参数的最接近的整数
ceil(42.2)
→ 43
ceil(-42.8)
→ -42
|
ceiling ( numeric )
→ numeric
ceiling ( double precision )
→ double precision
大于或等于参数的最接近的整数 (与 ceil 相同)
ceiling(95.3)
→ 96
|
degrees ( double precision )
→ double precision
将弧度转换为角度
degrees(0.5)
→ 28.64788975654116
|
div ( y numeric,
x numeric )
→ numeric
y/x 的整数商(截断为零)
div(9, 4)
→ 2
|
erf ( double precision )
→ double precision
误差函数
erf(1.0)
→ 0.8427007929497149
|
erfc ( double precision )
→ double precision
互补误差函数 (1 - erf(x), 对于较大输入无精度损失)
erfc(1.0)
→ 0.15729920705028513
|
exp ( numeric )
→ numeric
exp ( double precision )
→ double precision
指数 (e 的给定次方)
exp(1.0)
→ 2.7182818284590452
|
factorial ( bigint )
→ numeric
阶乘
factorial(5)
→ 120
|
floor ( numeric )
→ numeric
floor ( double precision )
→ double precision
小于或等于参数的最接近整数
floor(42.8)
→ 42
floor(-42.8)
→ -43
|
gamma ( double precision )
→ double precision
Gamma 函数
gamma(0.5)
→ 1.772453850905516
gamma(6)
→ 120
|
gcd ( numeric_type, numeric_type )
→ numeric_type
最大公约数 (能将两个输入数整除而无余数的最大正数); 如果两个输入为零则返回 0; 适用于 integer, bigint, 和 numeric
gcd(1071, 462)
→ 21
|
lcm ( numeric_type, numeric_type )
→ numeric_type
最小公倍数 (两个输入的整数倍的最小的严格正数); 如果任意一个输入值为零则返回 0; 适用于 integer, bigint, 和 numeric
lcm(1071, 462)
→ 23562
|
lgamma ( double precision )
→ double precision
Gamma 函数绝对值的自然对数
lgamma(1000)
→ 5905.220423209181
|
ln ( numeric )
→ numeric
ln ( double precision )
→ double precision
自然对数
ln(2.0)
→ 0.6931471805599453
|
log ( numeric )
→ numeric
log ( double precision )
→ double precision
以10为底的对数
log(100)
→ 2
|
log10 ( numeric )
→ numeric
log10 ( double precision )
→ double precision
以10为底的对数 (与 log 相同)
log10(1000)
→ 3
|
log ( b numeric,
x numeric )
→ numeric
以b为底对参数x取对数
log(2.0, 64.0)
→ 6.0000000000000000
|
min_scale ( numeric )
→ integer
精确表示所提供值所需的最小刻度(小数位数)
min_scale(8.4100)
→ 2
|
mod ( y numeric_type,
x numeric_type )
→ numeric_type
y/x的余数;
适用于smallint、integer、bigint和numeric
mod(9, 4)
→ 1
|
pi ( )
→ double precision
π的近似值
pi()
→ 3.141592653589793
|
power ( a numeric,
b numeric )
→ numeric
power ( a double precision,
b double precision )
→ double precision
a的b次幂
power(9, 3)
→ 729
|
radians ( double precision )
→ double precision
将角度转换为弧度
radians(45.0)
→ 0.7853981633974483
|
round ( numeric )
→ numeric
round ( double precision )
→ double precision
四舍五入到最近的整数。对于numeric,通过从零舍入来截断平局。
对于double precision,平局解决行为取决于平台,但“round to nearest even”是最常见的规则。
round(42.4)
→ 42
|
round ( v numeric, s integer )
→ numeric
将 v 四舍五入到 s 位小数。
当出现平局时,通过远离零的方向进行四舍五入来解决。
round(42.4382, 2)
→ 42.44
round(1234.56, -1)
→ 1230
|
scale ( numeric )
→ integer
参数的刻度(小数部分的位数)
scale(8.4100)
→ 4
|
sign ( numeric )
→ numeric
sign ( double precision )
→ double precision
参数的符号 (-1, 0, 或 +1)
sign(-8.4)
→ -1
|
sqrt ( numeric )
→ numeric
sqrt ( double precision )
→ double precision
平方根
sqrt(2)
→ 1.4142135623730951
|
trim_scale ( numeric )
→ numeric
通过删除尾数部分的零来降低值的刻度(小数位数)
trim_scale(8.4100)
→ 8.41
|
trunc ( numeric )
→ numeric
trunc ( double precision )
→ double precision
截断为整数(向零靠近)
trunc(42.8)
→ 42
trunc(-42.8)
→ -42
|
trunc ( v numeric, s integer )
→ numeric
截断 v 到 s 位小数
trunc(42.4382, 2)
→ 42.43
|
width_bucket ( operand numeric, low numeric, high numeric, count integer )
→ integer
width_bucket ( operand double precision, low double precision, high double precision, count integer )
→ integer
返回在具有 count 个等宽桶的直方图中
operand 所在的桶的编号,桶的范围为
low 到 high。
桶的下界是包含的,上界是排除的。
对于小于 low 的输入,返回 0,
对于大于或等于 high 的输入,返回
count+1。
如果 low > high,
行为将会反转,桶 1 现在是位于
low 之下的桶,包含的边界现在位于上侧。
width_bucket(5.35, 0.024, 10.06, 5)
→ 3
width_bucket(9, 10, 0, 10)
→ 2
|
width_bucket ( operand anycompatible, thresholds anycompatiblearray )
→ integer
返回在给定包含桶的下界的数组中
operand 所在的桶的编号。
对于小于第一个下界的输入,返回 0。
operand 和数组元素可以是
任何具有标准比较运算符的类型。
thresholds 数组 必须排序,
从小到大,否则将会得到意外的结果。
width_bucket(now(), array['yesterday', 'today', 'tomorrow']::timestamptz[])
→ 2
|