October 23, 2011

UNPIVOT in SQL Server

In last post i tried to demonstrate how can we use PIVOT in SQL Server.
In this post i am just going to describe where we can use UNPIVOT.

Let’s create an example for this.
I will take sample data from my last post.

image

This is our sample data and now i want to display this data as below format.

image

Here is T-SQL

image

That’s It.
Enjoy Learning.

No comments:

Post a Comment