Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I have record as follows:
Name Date        Status
AAA  01/02/2011   P
AAA  01/03/2011   P 
AAA  01/04/2011   A
BBB  01/02/2011   P
BBB  01/03/2011   P 
BBB  01/04/2011   A
CCC  01/02/2011   P
CCC  01/03/2011   P 
CCC  01/04/2011   A


I want result as :

Name  01/02/2011 01/03/2011 01/04/2011 
AAA   P            P           A  
BBB   P            P           A  
CCC   P            P           A  



Please help me.

Thanking you Mohd Wasif


[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 29-Jun-11 3:28am
v3

Look at using a PIVOT table: MSDN[^]
 
Share this answer
 
Comments
Mohd Wasif 30-Jun-11 9:17am    
I tried my best but unable to find the exact solutions
Please help.
SQL
SELECT Name,
CASE WHEN Date = '01/02/2011' THEN Status END AS [01/02/2011],
CASE WHEN Date = '01/03/2011' THEN Status END AS [01/03/2011],
CASE WHEN Date = '01/04/2011' THEN Status END AS [01/04/2011]
FROM TableName
 
Share this answer
 
Comments
Mohd Wasif 22-Jul-11 8:43am    
Status Column is Showing as NULL

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