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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Returning grouped data as single rows?

Author  Topic 

jaroot
Starting Member

46 Posts

Posted - 2005-12-29 : 16:09:29
What I'm trying to do is return multiple rows as single rows based on a grouping of a particular ID.

Say you have a table with movies for instance:
tblMovie
ID - TYPEID - MOVIENAME
1 - 1 - LOTR1
2 - 1 - LOTR2
3 - 2 - JAWS1
4 - 2 - JAWS2

I want to return this as two rows that look like this
TYPEID - MOVIENAME
1 - LOTR1, LOTR2
2 - JAWS1, JAWS2

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-12-29 : 16:19:54
http://www.sqlteam.com/item.asp?ItemID=11021

Tara Kizer
aka tduggan
Go to Top of Page

jaroot
Starting Member

46 Posts

Posted - 2005-12-29 : 16:26:15
Awesome.. thanks!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-12-30 : 00:10:38
Refer this also which uses Function approach
http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx?Pending=true

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

i_love_techno
Starting Member

4 Posts

Posted - 2005-12-30 : 11:16:58
quote:
Originally posted by madhivanan

Refer this also which uses Function approach
http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx?Pending=true

Madhivanan

Failing to plan is Planning to fail



Heh, nice.. So simple too. For some reason I was using a recursive UDF to pull off the same thing, don't know why I didn't think about this route! It's a little cleaner, and probly faster. thx!

Find happiness in listening to your discontent.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-02 : 01:45:27
>> It's a little cleaner, and probly faster. thx!

Yes Function approach is much faster than other methods

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -