>select distinct(vou_no)as vou_no,MAX(acc_code)as acc_code,MAX(date)as date,MAX(code2)as code2, >SUM(case type when 'P' then dr_amount else 0 end)as bamount, >SUM(case type when 'A' and acc_code='4102021' then dr_amount else 0 end)as s_tax, >SUM(case type when 'A' and acc_code='4102022' then dr_amount else 0 end)as w_tax, >SUM(case type when 'A' and acc_code='4102023' then dr_amount else 0 end)as f_fee, >SUM(case type when 'A' and acc_code='4102024' then dr_amount else 0 end)as s_fee > from crprp > group by vou_no >>
(case when type = 'A' and acc_code='4102021'