行列互转,重新命名排序

    SELECT rq 
        , sum (case when dl = 'MDT' then lw else 0 end) MDTLW 
, Count(case when dl = 'MDT' then lw else 0 end) MDTRC
        , sum (case when dl = '普通' then lw else 0 end) 普通
        , sum (case when dl = '特需' then lw else 0 end) 特需
        , sum (case when dl = '专家' then lw else 0 end) 专家
    FROM [表] where yggh='123456'  group by rq

你可能感兴趣的:(学习笔记)