select * from (SELECT datepart(hour,oper_date) AS oper_date, COUNT(*) AS voice_sum
FROM tb_voice_info
where CONVERT(char(10), oper_date, 120)=CONVERT(char(10), getdate(), 120)
GROUP BY datepart(hour,oper_date))
as p
PIVOT
(
SUM(voice_sum) FOR
p.oper_date IN ([0],[1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13],[14],[15],[16],[17],[18],[19],[20],[21],[22],[23])
) AS T
版权声明:本文为Ms___原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。