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

解决方案 »

  1.   

    可能是小弟没有表达清楚。
    当为001或为002或为003时,求if_feeinfo.tot_cost的值。
    不好意思
      

  2.   


    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
      

  3.   

    你说的求值啥意思.求和?不知道是不是你想要的
    1. sum(decode(fee_code,'001',fee_code,'002',fee_code,'003',fee_code,0)) as ypfee2. where fee_code in('001','002','003')
      

  4.   

    sum(decode(if_feeinfo.fee_code,'001',if_feeinfo.tot_cost,'002',if_feeinfo.tot_cost,'003',if_feeinfo.tot_cost,0)) as ypfee
    你是这个意思么?
      

  5.   

    xiaoxiao1984(笨猫儿^_^)使用函数decode()和in()
      

  6.   

    恩,当为001或为002或为003,求if_feeinfo.tot_cost的和。
      

  7.   

    方法1:
    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