I am having an issue figuring out how to pivot on the following. I want to know the counts based on three columns.
Column one: Authorization Status with option active or closed
Column two: Unique ID
Column three: Agency
I would like the end result to be:
Authorization Status Agency 1 Agency 2
Active 5 10
Closed 20 30
Thank you
Shubham KumarPosted Apr 2, 2016, 3:32 AM
SELECT Authorization_Status,[Agency 1],[Agency 2] FROM
(
SELECT Authorization_Status,UniqueID,Agency FROM #yourtable
)t PIVOT (SUM(UniqueID) FOR Agency IN ([Agency 1],[Agency 2])) AS A