Click here to Skip to main content
15,921,203 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

Can you tell me how to display different values of rows in one row.

Suppose my output is something like this:

id    name    marks
001    abc     23
001    abc     25
001    abc     20
001    abc     24
001    abc     28
002    def     19
002    def     25
002    def     26



and my expected output is this:

id    name    marks
001   abc     23,25,20,24,28
002   def     19,25
003   acs     26,20,22



Please tell me how do i write the procedure query..?
can you give me an example for the above question...??


[edit]Code block added, "Ignore HTML..." option disabled - OriginalGriff[/edit]
Posted
Updated 29-Jul-11 23:32pm
v3

You need a PIVOT table: MSDN[^]
 
Share this answer
 
Comments
Espen Harlinn 30-Jul-11 7:17am    
Good idea!
Griff is right. Also you can do that by using below alternate ways.

Pivoting data in SQL Server[^]
 
Share this answer
 
Comments
Espen Harlinn 30-Jul-11 7:17am    
Another good idea!

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