I am trying to run a query that lists all the distinct markets a user has submitted to for my dataset.
The values in the Markets column are already in an array format. When I run the query below, I get an array of arrays and some markets may be listed multiple times because the distinct clause is looking at the unique arrays and not the values in the arrays.
For example if I'm trying to group ['New York'] and ['New York' , 'Chicago'], my goal is to get ['New York', 'Chicago'] as my result, but am currently getting [['New York'],['New York', 'Chicago']]. Appreciate any assistance.
SELECT
s.submitter_id,
ARRAY_AGG(DISTINCT s.markets)
FROM
analytics.submissions AS s
GROUP BY 1
