1. sum( case fee_code when '001' then A -- fee_code = '001'则A语句处理
when '002' then B
when '003' then C
else D
end ) as ypfee2. sum(decode(fee_code,'001',A,'002',B,'003',C,D)) as ypfee
when '002' then B
when '003' then C
else D
end ) as ypfee2. sum(decode(fee_code,'001',A,'002',B,'003',C,D)) as ypfee
当为001或为002或为003时,求if_feeinfo.tot_cost的值。
不好意思
1. sum( case when fee_code in ('001','002','003') then A
else D
end ) as ypfee2. sum(decode(fee_code,'001',A,'002',A,'003',A,D)) as ypfee
1. sum(decode(fee_code,'001',fee_code,'002',fee_code,'003',fee_code,0)) as ypfee2. where fee_code in('001','002','003')
你是这个意思么?
sum(decode(if_feeinfo.fee_code , '001',if_feeinfo.tot_cost, '002' ,if_feeinfo.tot_cost,'003',if_feeinfo.tot_cost,0 )) as ypfee方法2:
select sum(case when if_feeinfo.fee_code in ('001','002','002') then if_feeinfo.tot_cost else 0 end case) as ypfee方法3:
select sum(decode(decode(if_feeinfo.fee_code,'001',1,'002',1,'003',1,0),1,if_feeinfo.tot_cost,0)) as ypfee