How to split values in a cell separated by a specific character


1 comment

  • Avatar
    Scott Bowen

    Here's another example of splitting the data into separate rows while keeping the rest of the data from the other columns.

    Let's say you have data showing t-shirt orders over time, and one of the fields lists the individual sizes in that order:

    If you would like to give each item in it's own row, but still show the order date, order number, and email associated with the order, you can use this SQL:

    unnest(string_to_array("Order_items", ',')) AS "Shirt size"
    FROM report;

    And you will end up with this data:

    Comment actions Permalink

Please sign in to leave a comment.