oracle decode nvl nvl2 sign(即sin) 函数用法

select decode(p.xx,1,'no1',2,'no2') from person p
这样只能做等于,如果xx等于1就显示no1,等于2显示no2;

当我们需要做大于小于判断的时候就要借助sign函数了,select decode(sign(p.reportDate-p.finishDate),1,p.reportDate,0,p.reportDate,-1,'') from person p,如果reportDate减去finishDate是个正数则sign函数返回1,负数为-1,0为0, 

NVL(EXPR1,EXPR2)
若EXPR1是NULL,则返回EXPR2,否则返回EXPR1.
SELECT NAME,NVL(TO_CHAR(COMM),'NOT APPLICATION') FROM TABLE1;

Use   of   the   New   NVL2   Function    
  Most   of   us   are   familiar   with   the   NVL   function   which   checks   for   the   existence   of   NULL   values.   Oracle   provides   a   new   function   called   NVL2   which   checks   for   the   existence   of   NOT   NULL.   The   syntax   for   this   function   is   as   follows.
  NVL2(expr1,expr2,expr3);  
  If   expr1   is   not   null   then   the   function   will   return   expr2.   Otherwise,   the   function   will   return   expr3.   The   expr1   can   have   any   datatype   and   arguments   expr2   and   expr3   can   be   of   any   datatype   other   than   LONG.   The   datatype   of   the   return   value   is   that   of   expr2. 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值