TCCode JobCode 总计 ------ -------- ----------- L402 A 1 L402 F 16 L402 H 1 L402 小号 12 L402 W 12 L603 A 1 L603 F 5 L603 S 8 L603 W 8
我的查询:
SELECT * FROM
(
Select TCCode, JobCode, count(*) AS Totals
From myTable
Group By JobCode, TCCode
) t1
pivot ( Count (JobCode) for JobCode in ([A], [S], [H], [F], [W])) as Totals
该表如上所示。我什么都试过了!我没有得到我想要的结果。我希望它是旋转的。我该怎么做呢?我在 SQL Server 2008 上。提前致谢!