可能重复:
在 T-SQL 中透视数据
请在查询中进行必要的更改以创建数据透视表显示...
select COUNT(employeeid) as count_of_employees,Title
from HumanResources.Employee
group by Title order by no_of_employees desc
此查询返回以下结果
count_of_employees Title
26 Production Technician - WC50
26 Production Technician - WC60
26 Production Technician - WC40
25 Production Technician - WC30
22 Production Technician - WC20
17 Production Technician - WC10
15 Production Technician - WC45
14 Sales Representative
9 Buyer
5 Marketing Specialist
4 Scheduling Assistant
我需要想要的结果
Production Technician-WC50 | Production Technician-WC60 | Production Technician-WC40
26 | 26 | 26