October 23, 2011

PIVOT in SQL Server

We have heard about pivoting in Excel but can we do same type of actions in SQL Server?
Yes we can do we have PIVOT keyword in SQL Server.
Let’s try to create a scenario wherein we can use it.

I have written lot of posts on my blog in last couple of months i want to summarize it
according month wise.

This is my actual data.

image

Now i want output should come in this way.

image

Here we will use PIVOT to do it.

T-SQL

image

That’s It.
Enjoy Learning.

No comments:

Post a Comment