Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In MS Access database as follows:
Date          Session   Course     Faculty_Code

25/01/2013      1       AFF             GS
25/01/2013      1       AFF             VB

I would like the output as follows:
Date          Session   Course     Faculty_Code

25/01/2013      1       AFF             GS,VB

When I tried your query output shows as follows:

I tried with this query:
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
PIVOT Tb_SCh_TIme_Table.Session;

When I tried your query output shows as follows;
Date          Session   Course     Faculty_Code

25/01/2013      1       AFF             GS

In the above output not showing the Two faculty name only shows the GS Faculty_Code. I would like the VB Faculty_Code also.

I need the final output as follows:
Date          Session   Course     Faculty_Code

25/01/2013      1       AFF             GS,VB.


For the same date, session and course, different faculty takes class I need to mention both Faculty_Code also.

How can I write the query to get the final output as I mentioned above.

Please help me. How can I do it?


Thanks.
Posted
Updated 25-Jan-13 21:36pm
v3
Comments
Richard MacCutchan 26-Jan-13 4:50am    
Who are you directing this message to?

1 solution

Hi,
Can you try the below SQL

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