Skip to content
Advertisement

Include Column name in SQL Unpivot

I have an unnormalized data set I need to normalize for reporting purposes.

enter image description here

I successfully unpivoted the data using this:

enter image description here

How can unpivot column headers Question1, Question2, Question3, Question4 as a third column in my unpivot query, like this?

enter image description here

Advertisement

Answer

Your syntax looks like SQL Server. If so, just use a APPLY:

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