Oracle学习笔记5-内置函数之数值函数

来源:互联网 发布:手机淘宝退款怎么取消 编辑:程序博客网 时间:2024/05/19 15:40

            首先,我们用列出Oracle中主要的数值函数,如下;

          

          捎带介绍下dual表,该表是一个Oracle的工作表,只包含一个列和一个行的标准表,它被用作一个虚拟表,当我们需要展示Oracle内置函数的功能时,建议用该表。

          下面我们对常用的几个数值函数进行简单的讲解;

         1. BITAND

         是位与函数,即按位相与,是对两个参数进行‘与’操作,且这两个参数必须是非负值,一般与decode配合使用。其返回结果为整数。示例如下;

      select stu_id , decode(bitand(stu_state,1),1,'house'.'bird')from student where stu_state<30; (stu_state为一时显示为‘house)

      select stu_id , decode(bitand(stu_state,2),2,'red'.'green’)from student where stu_state<30; (stu_state为二时显示为‘red)

       2. ceilfloor

       ceil返回大于等于特定值的最小整数

       select ceil  (1.22) from dual ----2

       floor返回小于等于特定值的最小整数

       select floor1.22from dual ---1

     3.signparam

     根据参数决定返回10-1

      param  >  0  -->1

      param  <  0  ->-1

      param   =  0  -> 0

    4.roundx , y)和trunc

     返回四舍五入到特定位置y位小数的x值(y可不写,默认为1,将x裁为整数)

     select round123.11),round1.255682),round235.125-1from dual------》》 123   1.26  240

     和前者相比trunc只是裁剪到指定的位置而不四舍五入

 

 

 

 

 

 

 

 

原创粉丝点击