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 |
|
maximation
Starting Member
6 Posts |
Posted - 2008-08-05 : 11:41:54
|
| I need to group the records by Restaurant and RoomStatus within one column per Restaurant-- My Desire output need to look like this10 Yonos Restaurant Room A- Incomplete Certification ; Room B- complete Certification Room C- complete Certification25 Atlanta Fish Market Room 101- complete Certification; Room 102- Incomplete Certification Is there a quick way to achieve this any help would be highly appreciated. my query currently looks like this with the output as followsselect d.intvenue_fk as PK,v.nvcVenue_Name as Restaurant,nvcDining_Name+'- '+cs.nvcCertificationStatus as RoomStatusFROM tblDining dinner join tblVenue v on v.intVenue_pk=d.intVenue_fkinner join tblCertStatus c on c.intCertificationStatus_pk=d.intCertificationStatus_fk--PK-- --Restaurant-- --RoomStatus--10 Yonos Restaurant Room A- Incomplete Certification10 Yonos Restaurant Room B- complete Certification10 Yonos Restaurant Room C- complete Certification25 Atlanta Fish Market Room 101- complete Certification25 Atlanta Fish Market Room 102- Incomplete Certification |
|
|
Vinnie881
Master Smack Fu Yak Hacker
1231 Posts |
Posted - 2008-08-05 : 11:52:18
|
| I'm not following, can yo please clarify more? What is the current output? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-05 : 13:08:19
|
| [code]SELECT m.PK,m.Restaurant,LEFT(rl.roomlist,LEN(rl.roomlist)-1) AS RoomStatusListFROM (SELECT DISTINCT PK,Restaurant FROM YourTable)mCROSS APPLY (SELECT RoomStatus +';' AS [text()] FROM YourTable WHERE PK=m.PK AND Restaurant=m.Restaurant FOR XML PATH(''))rl(roomlist)[/code] |
 |
|
|
|
|
|