Hello Friends,

Here is another popular lab from Hands-On-Lab library: Pivoting in SQL Server.

To understand and analyze the data in more efficient way, we may have to rotate rows into columns and columns into rows. The rotation of rows to columns is called pivoting and the reverse operation is called unpivoting. This lab explains pivoting and unpivoting operation using manual coding using CASE statement(s) and by using PIVOT and UNPIVOT operators. This lab is divided into four exercises. In the first exercise, we will learn the concept of pivoting. In the second exercise, we will learn the pivoting and grouping in the presence of IDENTITY column and also will learn dynamic pivoting. In the third exercise, we will learn the performance differences between pivoting using CASE statement(s) and PIVOT operator. In the fourth and final exercise, we will learn to unpivot the pivoted data.

Exercise 1: Introduction to Pivoting
Exercise 2: Pivot Operator Internals
Exercise 3: Performance comparison between manual pivoting and PIVOT operator
Exercise 4: Unpivoting the data
Exercise 5: T-SQL Challenge

SQLMaestros Hands-On-Labs enables the practical way of learning. Each lab document consists of multiple exercises and each exercise consists of multiple tasks. Apart from step-by-step instructions, the HOL document contains images, explanations, observations, notes, tips & tricks to ensure a great learning experience. With each lab, you can practice a specific concept step-by-step. With our HOL documents, you will get hands-on with hundreds of topics in SQL Server & Microsoft Data Platform. Learn More.

 

 

Happy Learning – The Practical Way.