Skip to content
Advertisement

Unpivot pairs of associated columns to rows

I have a table with staggered article prices like this:

I want to transpose that into this structure:

Can this be done with PIVOT/UNPIVOT in T-SQL, or do I have to use UNION?

Advertisement

Answer

CROSS APPLY (VALUES is the easiest way to unpivot usually, especially with multiple columns

Some more tricks you can do with CROSS APPLY

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