with temp as ( select * from 总表 group by 分类字段 )select sum(case when t.date = to_date(to_char(一月日期,'date日期格式'),'date日期格式') then 统计字段 else 0 end) as 一月份, .....................from temp t union select ' ' as 编号, sum........ sum....... from temp t ------------------------------------------------- 差不多这样子
( select * from 总表 group by 分类字段
)select
sum(case when t.date = to_date(to_char(一月日期,'date日期格式'),'date日期格式') then 统计字段 else 0 end) as 一月份,
.....................from temp t
union
select
' ' as 编号,
sum........
sum.......
from temp t
-------------------------------------------------
差不多这样子