Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Concatenate by Grouping Expand / Collapse
Author
Message
Posted Friday, October 25, 2013 10:46 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, December 18, 2014 4:39 PM
Points: 171, Visits: 683
Does anyone have any ideas on how to concatenate cells by a grouping of rows? The data below shows original and an example of how I'm trying to combine. Also attached an image of a table I put together with the same data.

Current Data
Agent Item Email
Aaron 123 abc@abc.com
Aaron 1256 def@def.com
Aaron 1256 ghi@ghi.com
Ben 143 jkl@jkl.com
Ben 143 mno@mno.com
Carl 156 pqr@pqr.com
Carl 156 stu@stu.com
Carl 156 vwx@vwx.com

Combined
Agent Item Emails
Aaron 123 abc@abc.com
Aaron 1256 def@def.com; ghi@ghi.com
Ben 143 jkl@jkl.com; mno@mno.com
Carl 156 pqr@pqr.com; stu@stu.com; vwx@vwx.com
Post #1508528
Posted Friday, October 25, 2013 11:22 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 11:57 AM
Points: 4,055, Visits: 9,229
It's really easy, just follow the instructions on this article:
http://www.sqlservercentral.com/articles/comma+separated+list/71700/

For a coded answer, please provide DDL and sample data in the form of insert statements.



Luis C.
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1508541
Posted Friday, October 25, 2013 12:01 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, December 18, 2014 4:39 PM
Points: 171, Visits: 683
Actually after a bit more digging I was able to find the answer here:

[url=http://www.sqlservercentral.com/Forums/Topic872409-392-1.aspx][/url]
Post #1508558
Posted Monday, October 28, 2013 2:59 PM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 11:57 AM
Points: 4,055, Visits: 9,229
It's the same way, but you should read the article (it's not long) to understand how does it work.


Luis C.
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1509122
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse