Click here to Skip to main content
12,069,894 members (67,182 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
My query as follows in ms access data base

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 26-Jan-13 6:59am
Edited 26-Jan-13 7:01am
ProgramFOX178.4K
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Hi,
Try with the below Query
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
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160208.1 | Last Updated 26 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100