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)
 crosstab query

Author  Topic 

dipra
Starting Member

1 Post

Posted - 2007-08-07 : 16:22:15
Hi
can anybody help me to solve this problem pls?
I can get records from multiple tables as bellow:

Item qnty price customer_type
1 100 50 PCY
1 200 50 WHPY
2 500 100 pcy
2 100 100 WHPY
3 50 200 PCY
BUT IF I WANT TO GET OUTPUT AS FOLLOWS WHAT I HAVE TO DO ?

Item Qnty(pcy) Price(pcy) Qnty(WHPY) Price(WHPY)
1 100 50 200 50
2 500 100 100 100
3 50 200 0 0

Thanks

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-08-07 : 22:06:19
You can use the PIVOT operator in SQL Server 2005

see http://msdn2.microsoft.com/en-us/library/ms177410.aspx


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -