Archive

Archive

create a comma-separated string from multiple rows

If you think of it, it's basically reverse engineer the process of "splitting a string into multiple rows".

I have a long list of values that are already split into different rows from the original data source, but now I want to put them back in a single string, separated by the commas.

How do I do that? my data is relatively large. 

sample of original data source:

customers_idcarrier_requested
342062UPS WSV
342062UPS GD
342062UPS 3D
194343UPS ST
194343UPS SP1
194343UPS WXP

 sample of ideal output:

customers_idcarrier_requested
342062UPS WSV, UPS GD, UPS 3D
194343UPS ST, UPS SP1, UPS WXP

Comments

  • Domo Employee

    So you'll need to use a SQL transform for your dataset.

     

    It would go something like this:

    1. SELECT `customers_id`, GROUP_CONCAT(`carrier_requested` SEPARATOR ', ') as 'carrier_requested'
      FROM data_source
      GROUP BY `customers_id`

    The MySQL GROUP_CONCAT function looks like what you'd want to use.

     

    Hope this helps,

    ValiantSpur

     

    **Please mark "Accept as Solution" if this post solves your problem
    **Say "Thanks" by clicking the "heart" in the post that helped you.

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In