Click here to Skip to main content
15,880,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
CSS
Id              Date         Attendance
LAB01           2012-06-01   P
FBD/SL/01/2012  2012-06-01   A
FBD/SL/05/2012  2012-05-01   P
LABOCP/121      2012-06-01   P
LABOCP/123      2012-06-01   P

LAB01           2012-06-02   P
FBD/SL/01/2012  2012-06-02   A
FBD/SL/05/2012  2012-05-02   P
LABOCP/121      2012-06-02   P
LABOCP/123      2012-06-02   P

LAB01           2012-06-03   P
FBD/SL/01/2012  2012-06-03   A
FBD/SL/05/2012  2012-05-03   P
LABOCP/121      2012-06-03   P
LABOCP/123      2012-06-03   P

LAB01           2012-06-05   P
FBD/SL/01/2012  2012-06-05   A
FBD/SL/05/2012  2012-05-05   P
LABOCP/121      2012-06-05   P
LABOCP/123      2012-06-05   P


I would like to flip the rows to be columns so that this table looks like this in Gridview.
CSS
Id              2012-06-01 2012-06-02  2012-05-03   2012-06-04   2012-06-05    TP     
LAB01           P           P           P               -           P         4
FBD/SL/01/2012  A           P           P               -           P         3
FBD/SL/05/2012  P           A           P               -           P         3
LABOCP/121      P           P           A               -           P         3
LABOCP/123      P           P           P               -           A         3
Posted
Updated 21-Jun-12 21:32pm
v2

You must try: Pivot Table[^]

Have a look for more examples:
Pivot tables in SQL Server. A simple sample.[^]

Here are more detailed description of PIVOT: http://msdn.microsoft.com/en-us/library/ms177410(v=sql.105).aspx[^]
 
Share this answer
 
Comments
Vani Kulkarni 22-Jun-12 4:21am    
Ditto! 5!
Prasad_Kulkarni 22-Jun-12 5:46am    
I have answered it almost 1 hr before your post. You should check it before answering. If we both post our answer in very short difference of time then it would be accepted.
Manas Bhardwaj 22-Jun-12 6:11am    
Correct +5
Prasad_Kulkarni 22-Jun-12 6:28am    
Thank you Manas!

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