Click here to Skip to main content
15,884,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
My database structure of attendance table is like this
ID   EmpName        Date             Status
1    Raj           1/12/2012             P
2    Rahul         1/12/2012             P
3    Raj           2/12/2012             P
4    Rahul         2/12/2012             P
5    Raj           3/12/2012             A
6    Rahul         3/12/2012             P
7    Raj           4/12/2012             A
8    Rahul         4/12/2012             P


And i want to customize the output in following format
EmpName  1  2  3  4
Raj      P  P  A  A
Rahul    P  P  P  P


So please help me on above issue
Posted
Updated 2-Jan-13 0:56am
v2
Comments
AmitGajjar 2-Jan-13 6:37am    
Pivot may work for you.

1 solution

PIVOT is an option. You have two approaches listed here: http://stackoverflow.com/questions/10976585/convert-rows-to-columns-using-pivot-in-mssql-when-columns-are-string-data-type[^]. Look for the accepted answer. And you will get a playground also to test it.
 
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