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 2000 Forums
 Transact-SQL (2000)
 Dynamic Pivot for multiple columns

Author  Topic 

GirishKumarSharma
Starting Member

10 Posts

Posted - 2013-07-17 : 09:14:39
Hi,

I know, it is bad etiquette to post the same question link in other forum, but here it is my question link :

http://www.sqlservercentral.com/Forums/Topic1474579-8-1.aspx

I am sorry, to post the question in such a way, but if anyone can please help me by looking the above link, I shall be thankful for your help.

Just because I think in that forum, there is less activity, so I am trying here.

Thanks and Regards
Girish Sharma

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-07-17 : 11:31:03
[code]

SELECT code,
MAX(CASE WHEN department = 'AKD' THEN netqty END) AS NetQty_AKD,
MAX(CASE WHEN department = 'AKD' THEN netmrp END) AS NetMrp_AKD,
MAX(CASE WHEN department = 'MRI' THEN netqty END) AS NetQty_MRI,
MAX(CASE WHEN department = 'MRI' THEN netmrp END) AS NetMrp_MRI,
MAX(CASE WHEN department = 'PHYSIOTHERAPY' THEN netqty END) AS NetQty_PHYSIOTERAPY,
MAX(CASE WHEN department = 'PHYSIOTHERAPY' THEN netmrp END) AS NetMrp_PHYSIOTERAPY,
MAX(CASE WHEN department = 'SONO' THEN netqty END) AS NetQty_SONO,
MAX(CASE WHEN department = 'SONO' THEN netmrp END) AS NetMrp_SONO
FROM consumption
GROUP BY code
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2013-07-23 : 05:09:21
Also refer this post
http://beyondrelational.com/modules/2/blogs/70/posts/10791/dynamic-crosstab-with-multiple-pivot-columns.aspx

Madhivanan

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

- Advertisement -