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 by pains

Author  Topic 

ryager
Starting Member

3 Posts

Posted - 2007-08-29 : 09:28:35
Hello All,
I have a table (ATABLE) that contains the following

(int) (varchar)
UserID Company
1 ABC
1 DEF
1 GHI
2 ABC
2 DEF
3 ABC

I am trying to create a VIEW that will produce the following.

UserID Companies
1 ABC,DEF,GHI,
2 ABC,DEF,
3 ABC,

I have tried the following ->

select UserID, Sum(Company + ',')
from ATABLE
group by UserID

however I get an error that the SUM does not work with varchar

any ideas?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-29 : 09:32:17
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

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-08-29 : 09:34:54
1 If you use front end, then do concatenation there
2 http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81254

Madhivanan

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

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-08-29 : 09:35:59
Partly

Madhivanan

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

ryager
Starting Member

3 Posts

Posted - 2007-08-29 : 09:59:13
That worked GREAT thank you.

Go to Top of Page
   

- Advertisement -