If you PIVOT a table and then UNPIVOT it, do you get the original back? Not always. My PIVOT and UNPIVOT table examples show why aggregation loses data.
SQL SERVER – UNPIVOT Table Example
UNPIVOT Table is the reverse of PIVOT. This AdventureWorks example turns state columns back into rows, and shows why the detail rows do not return.
SQL SERVER – PIVOT Table Example
A PIVOT Table example on AdventureWorks that counts addresses by state, plus why UNPIVOT cannot always give you back the original rows.



