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 |
|
joemama
Posting Yak Master
113 Posts |
Posted - 2008-08-11 : 20:02:24
|
| is there a way to have a query show data like this...FAC FACNAME FACSUBNAME1 RWC ALM,COP,DGRand not thisFACID FACSUBIDFACNAME FACSUBNAME1 2 RWC ALM1 3 RWC COP1 3 RWC COP1 4 RWC DGRI have a facility table and a facilitysub table and need to have results show as in the first exampleany help would be appreciated |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-08-11 : 22:20:08
|
use PIVOT operator KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-11 : 23:53:15
|
| [code]SELECT DISTINCT FAC,FACNAME,STUFF(SELECT FACSUBNAME + ',' AS [text()] FROM YourTable WHERE FAC=t.FAC AND FACNAME =t.FACNAME ORDER BY FACSUBNAME FOR XML PATH('')),1,1,'')FROM YourTable t[/code] |
 |
|
|
|
|
|