Click here to Skip to main content
15,882,055 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My query as follows in ms access data base

SQL
TRANSFORM First(Tb_SCh_TIme_Table.Faculty_Code) AS a
SELECT Tb_SCh_TIme_Table.Sch_Date, Tb_SCh_TIme_Table.Course
FROM Tb_SCh_TIme_Table
GROUP BY Tb_SCh_TIme_Table.Sch_Date, Tb_SCh_TIme_Table.Course,Tb_SCh_TIme_Table.Faculty_Code
PIVOT Tb_SCh_TIme_Table.Session

Output as follows;

Sch_Date    Course    1      2     3
12/01/2013  AFF       GS
12/01/2013  AFF       NR
13/01/2013  TFC                    GS
13/01/2013  TFC       VB    VB


From the above output I want the final output as follows;
Sch_Date    Course    1         2     3
12/01/2013  AFF       GS,NR
13/01/2013  TFC                       GS
13/01/2013  TFC       VB       VB

Using my above query how to get the output.


How can I do? Please help me.

[Edit]Code block added[/Edit]
Posted
Updated 26-Jan-13 6:01am
v2

Hi,
Try with the below Query
SQL
SELECT t1.Sch_Date,t1.Session,t1.Course,
       Faculty_Code =REPLACE( (SELECT Faculty_Code AS [data()]
           FROM [tb_SchTime_Table] t2
          WHERE t2.Sch_Date = t1.Sch_Date and t2.Course=t1.Course
            FOR XML PATH('')
            ), ' ', ',')
      FROM [tb_SchTime_Table] t1
      GROUP BY Sch_Date,Course,Session ;


Best Regards
Muthuraja
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900