Skip to content
Advertisement

SQL:pivot: convert each row into many rows depends on a condition

I have been trying to solve this but could not figure it out.

so this is the table and more columns could be added:

So if the value is one then I will display it in a different row but with the value being the column header itself My boss suggested using pivot to solve this but I am open to any way.

output should be like this:

Advertisement

Answer

One method is union all:

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