Korzystanie z programu SQL Server Pivot-Unpivot
Wybór artykułów na temat korzystania z SQL Server PIVOT
PIVOT and UNPIVOT in SQL Server can be used in some amazing ways. Using some real world examples, we are going to show you what can be done.
Each stage gets a bit more complex, so step through each if you can.
1: Using UNPIVOT
Turn columns into rows, for instance useful when you need to break up a large table with months as columns.
2: Using PIVOT
Turn rows into columns, great for displaying data on an SSRS report.
3: Using PIVOT with dynamic SQL
Use dynamic SQL to extend this function to any unknown column names.
4: Using PIVOT and UNPIVOT together
Combine the two to re-build a table without a mass of CASE statements, or transfer data in a neutral form.