只要判断就可以了
select case when 费用1 is null then 0 end 费用1,
case when 费用2 is null then 0 end 费用2,
case when 费用3 is null then 0 end 费用4,
from 表名
select case when 费用1 is null then 0 end 费用1,
case when 费用2 is null then 0 end 费用2,
case when 费用3 is null then 0 end 费用4,
from 表名
select case when 费用1 is null then 0 end 费用1,
case when 费用2 is null then 0 end 费用2,
case when 费用3 is null then 0 end 费用3
from 表名
FROM TBL
GROUP BY 人员
nvl(sum(decode(fee,'费用1',total)),0)费用1,
nvl(sum(decode(fee,'费用2',total)),0)费用2,
nvl(sum(decode(fee,'费用3',total)),0)费用3
from table
group by person;