现在又需求一个表
mc       a       b     c
小红     56      45     12
庄园     34      34     12想转换为
    小红    庄园
a   56       34
b   45       34
c   12       12
感谢高手回答

解决方案 »

  1.   

    如表字段test(f1 varchar,f2 bunmer)
    内容为:f1 f2
      A 10
      B 15
      C 11
    转换成列为:A B C
      10 15 11程序为:
     select sum(case when f1 = 'A' then f2 else 0 end) A,
      sum(case when f1 = 'B' then f2 else 0 end) B,
      sum(case when f1 = 'C' then f2 else 0 end) C
      from test
      group by f1;
      

  2.   

    楼主的这个需求,在之前有人曾经在论坛上发过,尚未有更好的答案,2L的这个是以为转多维.lz问的是横纵互转.