Click here to Skip to main content
Rate this: bad
good
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 5:59am
Edited 26-Jan-13 6:01am
ProgramFOX109.6K
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
0 Sergey Alexandrovich Kryukov 574
1 OriginalGriff 373
2 Damith Weerasinghe 355
3 thatraja 350
4 Abhinav S 230
0 Sergey Alexandrovich Kryukov 10,639
1 OriginalGriff 6,658
2 Peter Leow 4,735
3 Abhinav S 3,813
4 Maciej Los 3,565


Advertise | Privacy | Mobile
Web04 | 2.8.140421.2 | Last Updated 26 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid