Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to query for sales year with pivot ?

Author  Topic 

hdv212
Posting Yak Master

140 Posts

Posted - 2010-12-14 : 05:38:09
Hi
i want to create a query from northwind sample database to retrieve total sales year for all customers by year via pivot. something like this :

CID 1th-Quarter-97 2th-Quarter-97 3th-Quarter-97 4th-Quarter-97
Alfki 1400 2600 1300 1200

can anybody help me to accomplish this ?
thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-12-20 : 09:15:11
Make use of this
http://beyondrelational.com/blogs/madhivanan/archive/2008/08/27/dynamic-pivot-in-sql-server-2005.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -