MySQL数值处理函数

 

1round():四舍五入函数

round(数值,参数):如果参数的值为正数,表示保留几位小数,如果参数的值为0,则只保留正数部分们如果参数的值为负数,表示对小数点前第几位进行四舍五入。

Eg1select round(45.926,2) from dual

         

  2select round(45.926,1) from dual

     

  3select round(45.926,0) from dual

     

  4select round(45.926,-1) from dual

     

  5select round(45.926,-2) from dual

     

  6select round(51.926,-2) from dual

     

2ceil(数值):向上取整

Eg1select ceil(10.99) from dual

       

  2select ceil(10.11) from dual

     

 

3floor(数值):向下取整

Egselect floor(10.11) from dual

     

4mod(参数1,参数2):求出余数

Egselect mod(10,4)from dual

     

5sqrt(数值):求出平方根

Eg1select sqrt(9)from dual

        

  2select sqrt(10)from dual

        

6power(底数,指数):返回某数的乘幂

  2是底数,9是指数

Egselect power(10, 2) from dual

     

 

posted @ 2018-10-23 17:48  小白菜»  阅读(913)  评论(0编辑  收藏  举报