GBASE南大通用技术分享:GBase 8s 内置函数
标量函数
数学函数汇总
编辑
GBASE南大通用技术分享:GBase 8s ABS
ABS(NUM)
select abs(-5.6) as num1, abs(5.6) as num2 from dual;
> select abs(-5.6) as num1, abs(5.6) as num2 from dual;
num1 num2
5.60000000000000 5.60000000000000
1 row(s) retrieved.
>
GBASE南大通用技术分享:GBase 8s CEIL/FLOOR/ ROUND
ceil(num)
floor(num)
round(num)
select ceil(5.6) as f_ceil, floor(5.6)as f_floor, round(5.6) as f_round from dual;
> select ceil(5.6) as f_ceil, floor(5.6)as f_floor, round(5.6) as f_round from dual;
f_ceil f_floor f_round
6 5 6
1 row(s) retrieved.
>
select ceil(5.3) as f_ceil, floor(5.3)as f_floor, round(5.3) as f_round from dual;
> select ceil(5.3) as f_ceil, floor(5.3)as f_floor, round(5.3) as f_round from dual;
f_ceil f_floor f_round
6 5 5
1 row(s) retrieved.
>
select ceil(-5.6) as f_ceil, floor(-5.6)as f_floor, round(-5.6) as f_round from dual;
> select ceil(-5.6) as f_ceil, floor(-5.6)as f_floor, round(-5.6) as f_round from dual;
f_ceil f_floor f_round
-5 -6 -6
1 row(s) retrieved.
>
select ceil(-5.3) as f_ceil, floor(-5.3)as f_floor, round(-5.3) as f_round from dual;
> select ceil(-5.3) as f_ceil, floor(-5.3)as f_floor, round(-5.3) as f_round from dual;
f_ceil f_floor f_round
-5 -6 -5
1 row(s) retrieved.
>
MOD
mod(num1, num2)
select mod(10, 3) as f_mod from dual;
> select mod(10, 3) as f_mod from dual;
f_mod
1
1 row(s) retrieved.
>
POW/SQRT/ROOT
pow(num1, num2)
sqrt(num)
root(num1, num2)
select pow(2, 3) as f_pow3, sqrt(25) as f_sqrt, root(64, 3) as f_root from dual;
> select pow(2, 3) as f_pow3, sqrt(25) as f_sqrt, root(64, 3) as f_root from dual;
f_pow3 f_sqrt f_root
8.000000000000 5.000000000000 4.000000000000
1 row(s) retrieved.
>
EXP
exp(num)
> select exp(1) as f_exp from dual;
f_exp
2.718281828459
1 row(s) retrieved.
>
LN/LOGN/LOG10
ln(num)
logn(num)
log10(num)
select ln(2.718281828459) as f_ln, logn(2.718281828459) as f_logn, log10(1000) as f_log10 from dual;
> select ln(2.718281828459) as f_ln, logn(2.718281828459) as f_logn, log10(1000) as f_log10 from dual;
f_ln f_logn f_log10
1.000000000000 1.000000000000 3.000000000000
1 row(s) retrieved.
>
SIN/COS
sin(num)
cos(num)
select sin(1) as f_sin, cos(1) as f_cos from dual;
> select sin(1) as f_sin, cos(1) as f_cos from dual;
f_sin f_cos
0.841470984808 0.540302305868
1 row(s) retrieved.
>