Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-04-18 : 07:13:32
|
| Naga Kiran writes "Is there any equivalent in SQL Server like "group_concat()" in mysql..i have a table with columns author_id,book_title..Now i want to make a query which will dogrouping by author_id and want to display the list of books authored by him delimited by a seperator in a seperate columncan i achieve this without using procedures in SQL ServerThanx in advance" |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2005-04-18 : 08:50:00
|
| any chance of sample data???...and matching expected results?or are we to be "most-excellent-mind-readers"??? |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-04-18 : 09:41:14
|
http://dev.mysql.com/doc/mysql/en/group-by-functions.htmlIf I'm reading this correctlyUSE NorthwindDECLARE @x varchar(8000)SELECT @x = COALESCE(@x+', ','')+ISNULL(ShipName,'') FROM ORdersSELECT @x Brett8-) |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-04-18 : 10:21:13
|
| >>grouping by author_id and want to display the list of books authored by him delimited by a seperator in a seperate columnThe easiest way is to use a technique similiar to what Brett has posted, but put it into a UDF which accepts an AuthorID as a parameter. Then, for your final desired result, you simply query the Authors table and call the UDF for each AuthorID, which will return the comma-separated list of book. Also, it is often much, much easier and more efficent to do formatting like this at the presentation layer.- Jeff |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-04-18 : 10:54:01
|
quote: Originally posted by X002548 If I'm reading this correctly
I guess reading may have been the wrong choic of words...But Jeff's suggestion with the udf would be the way to go....Know what a udf is?Brett8-) |
 |
|
|
|
|
|