现在一张表 t 
有如下记录
id a b c mc
1 12 13 14 ""
2 5 6 7 ""
3 7 8 9 ""要求查询出来的结果为
id mc a b c
1 1总计 39
1 1a 12
1 1b 13
1 1c 14
2 2总计 18
2 2a 5
2 2b 6
2 2c 7
3 3总计 24
3 3a 7
3 3b 8
3 3c 9
能不能用一条SQL语句实现,或是其它方法,最好用一条SQL查询出来

解决方案 »

  1.   

    一条查询就可以在CSDN找到很多种解决方法。
    :D
    先找找看吧!
      

  2.   

    select * from
    (
    select id,to_char(id)+'a',a from t
    union all
    select id,to_char(id)+'b',b from t
    union all
    select id,to_char(id)+'c',c from t
    union all
    select id,to_char(id)||'總計',a+b+c from t) t
    order by id
      

  3.   

    to_char(id)+'a',to_char(id)||'總計',为什么一个用"+",一个用||呀?
    "+"好象不行哦