语法
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)