Skip to content
Advertisement

Convert rows to columns using PIVOT

I have a table named AmountList in SQL Server :

AmountList

where Primary key is ” UniqueCol1, UniqueCol2, AmountID “

and on the basis of AmountID I want to Pivot the results as:

enter image description here

I am facing the challenge using Pivot because only Aggregate functions can be used but I need actual values of the fields.

UPDATE: Added my attempt for the solution using JOINS, but need some query with higher performance.

Advertisement

Answer

You can use case expressions to achieve your expected output.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement