我有这张桌子:
Person Job
PersonA XX
PersonA XX
PersonA XX
PersonB XX
PersonB XX
PersonB YY
PersonB ZZ
PersonC XX
PersonC XX
PersonA XX
PersonA YY
PersonB ZZ
...
现在,我希望输出是这样的:
Job PersonA PersonB Person C
XX 4 2 2
YY 1 1 0
ZZ 0 2 0
到目前为止,我有这个:
SELECT DISTINCT Person,
(SELECT COUNT(Job)
FROM dbo.TableName
GROUP BY Job)
FROM dbo.ExcelImport
没运气 :(