Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: SQL-server-2005
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 2-Jan-13 1:33am
Edited 2-Jan-13 1:56am
@AmitGajjar at 2-Jan-13 6:37am
Pivot may work for you.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

PIVOT is an option. You have two approaches listed here:[^]. Look for the accepted answer. And you will get a playground also to test it.

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

  Print Answers RSS
0 OriginalGriff 6,045
1 DamithSL 4,611
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310

Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 2 Jan 2013
Copyright © CodeProject, 1999-2014
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