Click here to Skip to main content
11,572,389 members (39,915 online)
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 0:33am
Edited 2-Jan-13 0: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

Advertise | Privacy | Mobile
Web03 | 2.8.150624.2 | Last Updated 2 Jan 2013
Copyright © CodeProject, 1999-2015
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