日期:2014-05-17 浏览次数:20401 次
unitid applynum state
62361 1 1
62361 1 1
62361 1 2
62361 1 0
62361 1 3
SELECT UnitiD,[0] 未审核,[1] 已通过,[2] 未通过
FROM FormationApply f
PIVOT(SUM(f.ApplyNum) FOR f.State IN ([0],[1],[2])) AS pvt
ORDER BY unitid
unitid 未审核 已通过 未通过
62361 NULL 1 NULL
62361 NULL 1 NULL
62361 NULL NULL 1
62361 1 NULL NULL
62361 NULL NULL NULL
select UnitiD,
[0] 未审核,
[1] 已通过,
[2] 未通过
from (select unitid,applynum,[state] from FormationApply) f
pivot(count(ApplyNum) FOR [State] IN ([0],[1],[2])) AS pvt
order by unitid