Problem with row concatenation [modified]
-
Hi All, I have a Student table which has 3 fileds:- ID Name PartNo ---------------------- 1 Smith 3 1 Adam 1 1 Samuel 3 2 Gary 1 2 Johnson 2 3 Immanuel 4 3 Ryan 2 3 Irene 1 3 Pete 5 My problem is i need to group students based on IDs and the Name need to be a concatenation of names based on the PartNo in ascending order. The O/p need to be like:- ID Name --------------------------- 1 Adam Smith 2 Gary Johnson 3 Irene Ryan Immanuel Pete I am working with SQL 2000. Hope somebody can help me sort this out. Thanks In Advance. Payal:) -- modified at 22:57 Wednesday 17th October, 2007
-
Hi All, I have a Student table which has 3 fileds:- ID Name PartNo ---------------------- 1 Smith 3 1 Adam 1 1 Samuel 3 2 Gary 1 2 Johnson 2 3 Immanuel 4 3 Ryan 2 3 Irene 1 3 Pete 5 My problem is i need to group students based on IDs and the Name need to be a concatenation of names based on the PartNo in ascending order. The O/p need to be like:- ID Name --------------------------- 1 Adam Smith 2 Gary Johnson 3 Irene Ryan Immanuel Pete I am working with SQL 2000. Hope somebody can help me sort this out. Thanks In Advance. Payal:) -- modified at 22:57 Wednesday 17th October, 2007
Any particular reason you didn't go with the more traditional
FirstName, MiddleNames, Surname
format?
Upcoming FREE developer events: * Glasgow: SQL Server Managed Objects AND Reporting Services ... My website
-
Any particular reason you didn't go with the more traditional
FirstName, MiddleNames, Surname
format?
Upcoming FREE developer events: * Glasgow: SQL Server Managed Objects AND Reporting Services ... My website
-
Hi Colin, I was being given this table(Built by somebodyelse) to get the specified result. Thanks. Payal
-
Hi All, I have a Student table which has 3 fileds:- ID Name PartNo ---------------------- 1 Smith 3 1 Adam 1 1 Samuel 3 2 Gary 1 2 Johnson 2 3 Immanuel 4 3 Ryan 2 3 Irene 1 3 Pete 5 My problem is i need to group students based on IDs and the Name need to be a concatenation of names based on the PartNo in ascending order. The O/p need to be like:- ID Name --------------------------- 1 Adam Smith 2 Gary Johnson 3 Irene Ryan Immanuel Pete I am working with SQL 2000. Hope somebody can help me sort this out. Thanks In Advance. Payal:) -- modified at 22:57 Wednesday 17th October, 2007
I have one solution but dont know the syntax. So telling the logic only. execute the below tsql stmt select * from codeproj order by id,partno asc Result will be like this: 1 Adam 1 1 Samuel 2 1 Smith 3 2 John 1 2 king 2 Now create a cursor, fetch the data and concatinate in a variable also check for the condition ID. You need to write stored procedure for all these.
-
I have one solution but dont know the syntax. So telling the logic only. execute the below tsql stmt select * from codeproj order by id,partno asc Result will be like this: 1 Adam 1 1 Samuel 2 1 Smith 3 2 John 1 2 king 2 Now create a cursor, fetch the data and concatinate in a variable also check for the condition ID. You need to write stored procedure for all these.