select nvl(t.NAME, '合计') NAME,
sum(decode(t.vehicletypename, 'A1', j.totalhours, 0.00)) as A1,
sum(decode(t.vehicletypename, 'B2', j.totalhours, 0.00)) as B2,
sum(decode(t.vehicletypename, 'C1', j.totalhours, 0.00)) as C1,
sum(decode(t.vehicletypename, 'C2', j.totalhours, 0.00)) as C2,
sum(decode(t.vehicletypename, 'C3', j.totalhours, 0.00)) as C3,
sum(decode(t.vehicletypename, 'C4', j.totalhours, 0.00)) as C4,
sum(decode(t.vehicletypename, 'A3', j.totalhours, 0.00)) as A3,
sum(decode(t.vehicletypename, 'B1', j.totalhours, 0.00)) as B1,
sum(decode(t.vehicletypename, 'A2', j.totalhours, 0.00)) as A2,
sum(j.totalhours) as "合计"
from personinfo_view t, person_all_hours j
where t.ID = j.personid
group by rollup(t.NAME)