Pivoting in SQL
-
Anyone can please help me to understand pivoting in SQL
-
Anyone can please help me to understand pivoting in SQL
Using PIVOT and UNPIVOT - SQL Server | Microsoft Docs[^] Questions About Pivoting Data in SQL Server You Were Too Shy to Ask - Simple Talk[^] SQL SERVER - PIVOT and UNPIVOT Table Examples - SQL Authority with Pinal Dave[^] Google (or your preferred search engine) will find you lots more.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Using PIVOT and UNPIVOT - SQL Server | Microsoft Docs[^] Questions About Pivoting Data in SQL Server You Were Too Shy to Ask - Simple Talk[^] SQL SERVER - PIVOT and UNPIVOT Table Examples - SQL Authority with Pinal Dave[^] Google (or your preferred search engine) will find you lots more.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
We have a couple of tables that we have to un-pivot - one has 245+ columns and (on average) about 510k rows - it needs to be un-pivotted down to 8 columns, and the columns we need to pivot are a mix of int, float, and varchar. This means we have to cast all of the pivoted columns to varchar, and then re-cast in the unpivot clause. When we redesign the database (soon I hope), we won't have to un-pivot, but will instead have to pivot the columns into a schema the app can understand. Hopefully though, we won't have to do any un-pivoting/pivoting at all - it's a pretty expensive operation.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013