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 |
Delinda
Constraint Violating Yak Guru
315 Posts |
Posted - 2009-11-04 : 21:27:54
|
I've following tablet1TID----------0001000200030004*TID is a uniquet2TID | Cout | Posi---------------------------0001 | KT | 10001 | JB | 30002 | KT | 20002 | JB | 20003 | KT | 10003 | JB | 2*Relationship between t1 and t2 is a 1 to many -- 1 record in t1, 2 record in t2I want my resultset as follow,TID | KT | JB-------------------------------------------------0001 | 1 | 30002 | 2 | 20003 | 1 | 20004 | null | nullHow my SQL statement look's like? Me weak to play around with PIVOTNeed help |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-11-06 : 03:18:08
|
select TID,max(case when Cout='KJ' then Posi end) as KJ,max(case when Cout='JB' then Posi end) as JBfrom table2group by TIDMadhivananFailing to plan is Planning to fail |
|
|
|
|
|