Using Pivot in SQL Server

Its a great feature for showing the data accross the rows(In a 3 dimensional way).The result provid us with a nice looking report for analysis.

select * from
(
select Membercode,left(datename(month,transactiondate),3) as mmonth,Amount from AccountTransaction
) as a
PIVOT
(SUM(amount) FOR [mmonth] IN (May,Jun,Jul))
AS pp

 

pivot

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s