我就想用一条SQL把竖表显示成横表!

解决方案 »

  1.   

    你查一下case when
    例:
    select sum( case when xingbie='0' then 1 else 0 end) a,
           sum( case when xingbie='1' then 1 else 0 end) a
          from personbase
      

  2.   

    只是打印的话,导出或复制数据到excel,利用选择粘贴,将行变成列。
      

  3.   


    select name,sum(case subject when '数学' then source else 0 end) as '数学',          sum(case subject when '英语' then source else 0 end) as '英语',            sum(case subject when '语文' then source else 0 end) as '语文' 
              ...............from testtable group by name