I'm trying to perform a pivot on the below dataset, In some cases there is only one unique ID, in others 2 and some cases more. I want to pivot the data in a way that shows for each unique ClaimID, the ResponseRejectCode Values are x,y,z ; having a column for each. Keeping in mind that the reject code will not always be an int and can be MR for example.
I've reviewed the TechNet Example below; however, I cannot use the aggregate function for obvious reasons.
-- Pivot table with one row and five columns
SELECT 'AverageCost' AS Cost_Sorted_By_Production_Days,
0, 1, 2, 3, 4
FROM
(SELECT DaysToManufacture, StandardCost
FROM Production.Product) AS SourceTable
PIVOT
(
AVG(StandardCost)
FOR DaysToManufacture IN (0, 1, 2, 3, 4)
) AS PivotTable;
Any help or pointing me in the right direction would be greatly appreciated! Thank you