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)
 Concatenate results with sql to produce a single value

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-03-09 : 08:46:53
Tom writes "Hi,

I’m not sure if this is possible but a friend suggested you guys might be able to help.

I have a query which looks like...

select
country,
region,
count(H.hotelid) as hotels_in_region,
(select hotelcode from table where id = H.hotelid) as hotel_codes
from table
group by....

i need my results to look something like...


UK N.Yorkshire 4 102,103,104,105
UK Surrey 2 1010,1457
UK Sussex 3 145,156,145


With the (select hotelcode from table where id = H.hotelid) returning a single varchar concatenated string of the results.

Any ideas???

I’m using SQL Server 2000

Thanks"

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-03-09 : 08:56:26
see here http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx

----------------------------------
'KH'


Go to Top of Page
   

- Advertisement -