Thumb

Pivot Table in Sql Server 2012 | Convert Rows to columns using Pivot


11/4/2019 1:09:36 AM

Step 1:

In this tutorial I will show how to convert Rows to columns using Pivot. First open SQL server management studio. Then create table name as customer. This table contain to column. Now write some SQL commend to filter and show the data by using Pivot. Given bellow the SQL commend:

Step 2:

Select * from(SELECT LEFT(DATENAME(MONTH,[Created]),3) AS [MonthName]
FROM [dob].[Customer]) as S
PIVOT
(
COUNT([MonthName])
FOR[MonthName] IN(jan,feb,mar,apr,may,jun,aug,sep,oct,dec)
) AS PVT

Step 3:

Now exsiccate the query.

About Teacher

Image

Reza Karim

Software Engineer

More about him