Imagine I have this table:
Column A | Column B | Column C
------------------------------
111 X 10
111 Y 12
How can I query this table to show the results like these:
Column A | X | Y
-----------------------------------
111 10 12
You can perform this via a PIVOT. You can use either a static PIVOT where you know the number of columns that you want to rotate or you can use a dynamic PIVOT
Static Pivot (see SQL Fiddle with Demo)
Dynamic Pivot (see SQL Fiddle with Demo)
Both versions will give the same results. The second works when you have an unknown number of columns that will be transformed.