日期:2014-05-17 浏览次数:20729 次
select '1年' y,sum(1年) from tb
union all
select '2年' y,sum(2年) from tb
...
with t as
(select 1 as "1year", 2 as "2year", 3 as "3year"
from dual
union all
select 4 as "1year", 5 as "2year", 6 as "3year" from dual)
select year, sum(counts)
from (select *
from t unpivot(counts for year in("1year", "2year", "3year")))
group by year
order by 1;