码迷,mamicode.com
首页 > 数据库 > 详细

oracle数据库中decode函数的使用

时间:2020-01-22 11:16:56      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:16px   inf   ima   char   sele   rom   create   from   ret   

语法

decode(条件,值1,返回值1,值2,返回值2,...值n,返回值n,缺省值) 

函数含义

IF条件=值1THEN
RETURN(返回值1)
ELSIF条件=值2THEN
RETURN(返回值2)
......
ELSIF条件=值nTHEN
RETURN(返回值n)
ELSE
RETURN(缺省值)
ENDIF
注意,后面的缺省值是可以不写的。
技术图片

 

 

 
技术图片

 

 

select lb.contno,
decode(cont.conttype, ‘1‘, cont.appntno, ‘2‘, cont.insuredno),
decode(cont.conttype, ‘1‘, cont.appntname, ‘2‘, cont.insuredname),
to_date(lb.create_time),
to_char(lb.sum_total, ‘9999999990.99‘),
to_char(lb.sum_price, ‘9999999990.99‘),
to_char(lb.sum_tax, ‘9999999990.99‘),
lb.sid,
lb.managecom
from LIS_BUSI_TRANSACTIONS lb, lccont cont
where cont.contno = lb.contno
and lb.invoiceflag in (‘00‘)
and lb.successflag = ‘1‘
and not exists
(select 1 from lcgrpcont c where c.grpcontno = lb.contno)
and lb.sum_total > 0
and (cont.currency = ‘01‘ or cont.currency is null)
and not exists (select 1
from ljagetendorse a, LIS_BUSI_TRANSACTIONS b
where a.actugetno = b.sourceid
and a.getflag = ‘1‘
and b.ruleid in (‘3‘, ‘6‘, ‘10‘, ‘12‘)
and a.actugetno = lb.sourceid
and b.sid = lb.sid)

oracle数据库中decode函数的使用

标签:16px   inf   ima   char   sele   rom   create   from   ret   

原文地址:https://www.cnblogs.com/dongyaotou/p/12228010.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!