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.
| Author |
Topic |
|
Andy878
Starting Member
1 Post |
Posted - 2009-12-22 : 22:09:07
|
| Hi Guys,Need help with a pivot query.My query after joining couple of tables is like thisID NAME PLACE DATE001 A Sydney 1-Jun-2009001 A Macau 2-Jun-2009 001 A Texas 3-Jun-2009I want it to be displayed like thisID NAME SYDNEY MACAU TEXAS001 A 1-Jun-2009 2-Jun-2009 3-Jun-2009Please help!! |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-12-23 : 01:54:41
|
| select id,name,case when place ='sydney' then date end sydney,case when place ='macau' then date end macau,case when place ='texas' then date end texasfrom tablenameselect id,name,[sydney],[macau],[texas] from tablenamepivot (max(date) for name in ([sydney],[macau],[texas]))pvt |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|
|