1年  2年 3年
 1   2   3
 4   5   6
的到1年  52年   73年   9

解决方案 »

  1.   

    这种情况 还是考虑union all吧 
    select '1年' y,sum(1年) from tb
    union all
    select '2年' y,sum(2年) from tb
    ...
      

  2.   

    如果是oracle 11g,可以用pivot,unpivot函数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;