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 2005 Forums
 Transact-SQL (2005)
 Group multiple rows into one.

Author  Topic 

shedoks
Starting Member

10 Posts

Posted - 2007-09-14 : 07:42:33
Hi.

First i want to say hello to everyone.
I'm new here and i hope i'll find a lot of interesting things.

I have a problem.
I need to write a specific (for me) qvery.

scenario:
Two tables in 1:N relation.
tblFirm 1:N tblPhones

tblFirm
idFirm [PK, autonumber, not null]
name [nvarchar(50), null]


tblPhones
idPhone [PK, autonumber, not null]
idFirm [FK, int, not null]
phone


the following code:
[code]SELECT tblFirm.name, tblPhones.phone
FROM tblFirm INNER JOIN tblPhones ON tblFirm.idFirm=tblPhones.idFirm/code]
will return:

name phone1
name phone2
name phone3
etc...

i need to group this into one row. For example:

name phone1 phone2 phone3


I hope you understand what i wrote above. Thx

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-14 : 07:58:19
See http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81254



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

shedoks
Starting Member

10 Posts

Posted - 2007-09-14 : 10:33:08
thanks
i've posted there asking 4 little more help.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-14 : 10:51:07
Please read this blog
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Then I can work with something.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -