[Oracle] 函数用法集合

来源:互联网 发布:hdfs java api jar包 编辑:程序博客网 时间:2024/06/05 20:21

1  oracle中sign函数  

取数字n的符号,大于0返回1,小于0返回-1,等于0返回0 
 SQL> select sign( 100 ),sign(- 100 ),sign( 0 ) from dual;    
SIGN(123 ) SIGN(- 100 )   SIGN( 0 )   
--------- ---------- ---------   
    1            - 1           0    
Java代码 复制代码
SQL> select sign(100),sign(-100),sign(0) from dual;   
  
SIGN(123) SIGN(-100)   SIGN(0)   
--------- ---------- ---------   
    1           -1         0

转载:http://516263736.blog.163.com/blog/static/71411435201076102113831/


2    nvl  函数 nvl2 函数 

nvl(a,b) 如果a不为null 则返回a,如果a为null则返回b;
nvl2(a,b,c) ,如果a不为null 则返回b,如果a为null则返回c;

转载:http://ljhzzyx.blog.163.com/blog/static/38380312201031593049646/


3  DECODE 中的if-then-else逻辑
在逻辑编程中,经常用到If – Then –Else 进行逻辑判断。在DECODE的语法中,实际上就是这样的逻辑处理过程。它的语法如下:
DECODE(value, if1, then1, if2,then2, if3,then3, . . . else )

参考:http://database.51cto.com/art/201011/232740.htm