`

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

阅读更多

decode

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


sign

当我们需要做大于小于判断的时候就要借助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;

 

NVL2 (expr1, expr2, expr3)

若expr1不为NULL,返回expr2;为NULL,返回expr3。expr2和expr3类型不同的话,expr3会转换为expr2的类型

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics