Click here to Skip to main content
15,662,459 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello , following is my table data :

EmployeeDetailID Name AbsentDays Month
3 Vishal Patel 1 May-13
3 Vishal Patel 3 Jun-13
3 Vishal Patel 4 Jul-13

Now i want this data to be converted like below :
EmployeeDetailID Name May-13 Jun-13 Jul-13
3 Vishal Patel 1 3 4

Please help me out with the query and thnx in advance
Updated 4-May-14 21:41pm

Share this answer
You can do pivoting in sql..

follow the link below for more info.

Simple Way To Use Pivot In SQL Query[^]

It seems like same as your requirement.
Share this answer
Try this:
SELECT  EmployeeDetailID, name, [May-13],[Jun-13],[Jul-13]
(SELECT  EmployeeDetailID, name, AbsentDays, month FROM table1) AS src
  sum(AbsentDays) FOR month IN ([May-13],[Jun-13],[Jul-13])
)AS pvt
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