4
Answers

I want the mutiple row output in single row using sql server

narasiman rao

narasiman rao

10y
816
1
 
 Query as follows

select Faculty,Convert(char(7),sch1.[Schdate],100 )+'('+STUFF(
(select ','+ ltrim(rtrim([Course])) +'-S'+ltrim(rtrim([Session])) from Tb_Sch_Time_Table sch
where sch.Schdate = sch1.Schdate and sch.Faculty = sch1.Faculty
FOR XML PATH(''))
,1,1,'')+')' as Schedule from Tb_Sch_Time_Table sch1
group by schdate,Faculty
order by 1

When i run the above the query output as follows

Faculty     Schedule
CPG        Aug 26 (B Tech 1-S3,B Tech 1-S4)
CPG        Aug 28 (ETO-S3,ETO-S4)


i want the Aug28 date in first row not in second row.

But i want the output as follows
Faculty    Schedule
CPG        Aug26(B Tech 1-S3,B Tech 1-S4) Aug28(ETO -S3,ETO -S4) 
Answers (4)