12,241,814 members (51,981 online)
Rate this:
See more:
```select * FROM Tb_SCh_TIme_Table P PIVOT (MAX(Faculty_Code) FOR Session IN ([1],[2],[3] ,[4])) AS PVT  where course = 'PH2' order by course;
```
from my above query output as follows;
```date        course    1   2   3   4
15/1/2013     AFF     CM
15/1/2013     AFF     NR
```

i want the below output as follows;
``` date        course    1     2   3   4
15/1/2013     AFF     CM,NR
```
how can i do.

using `PIVOT `query we can concatenation the rows and put in a single row.

how can id using my above query.
Posted 22-Jan-13 19:59pm
Edited 23-Jan-13 0:52am
v2
Tharaka MTR 23-Jan-13 3:43am

this seems re-post of following question
http://www.codeproject.com/Questions/532803/howplustoplususeplustowoplusqueryplusmakeplusinplu

Rate this:

## Solution 2

Here is the complete query according to me

```SELECT *
FROM (
SELECT [Date],[Course],[Session],
SUBSTRING((SELECT ','+ [Faculty_Code]
FROM [Tb_SCh_TIme_Table ] dp2
WHERE dp2.[Date] = dp1.[Date] and dp2.[Course]=dp1.[Course] and dp2.[Session]=dp1.[Session]
FOR XML PATH('')), 2, 8000) AS [Faculty_Code]
FROM [Tb_SCh_TIme_Table ] dp1
GROUP BY [Date],[Session],[Course]
) P
PIVOT (
MAX([Faculty_Code])
FOR [Session] IN ([1],[2],[3] ,[4])
) AS PVT
WHERE [Course]='PH2'
```
v2

Top Experts
Last 24hrsThis month
 OriginalGriff 530 Dave Kreskowiak 360 Sergey Alexandrovich Kryukov 305 F-ES Sitecore 280 Richard MacCutchan 270
 OriginalGriff 9,983 F-ES Sitecore 5,058 Jochen Arndt 4,468 Dave Kreskowiak 4,338 Richard MacCutchan 4,061