SQL语句——03、数值类型函数

ROUND(列名|表达式,n)

四舍五入到小数点后的n位
idle> select round(458.734,0),round(458.734,1),round(458.734,-1) from dual;

ROUND(458.734,0) ROUND(458.734,1) ROUND(458.734,-1)
---------------- ---------------- -----------------
      459    458.7 460

idle>
TRUNC(列名|表达式,n)
截取到小数点后的n位


idle> select trunc(458.734,0),trunc(458.734,1),trunc(458.734,-1) from dual


TRUNC(458.734,0) TRUNC(458.734,1) TRUNC(458.734,-1)
---------------- ---------------- -----------------
      458    458.7 450

idle>
MOD(m,n)
求m除以n的余数


idle> select mod(10,3) from dual;

 MOD(10,3)
----------
  1

idle>
idle> select mod(3,10) from dual;

 MOD(3,10)
----------
  3

idle>
CEIL 取整 向上补1  和trunc相反
idle> select ceil(457.001) from dual;   后面只要有小数,就进一

CEIL(457.001)
-------------
   458

idle>
power(底数,指数) 求次方
SQL> select power(10,3) from dual;

POWER(10,3)
-----------
       1000

SQL>
 
 

相关推荐