Skip to content
Advertisement

SQL distinct values per group – how to “group by” and get a list of distinct values per group?

I need to do a bigquery/standard SQL statement (or a series of statements) that does “group by”, and returns a list of distinct values for each group (not count).

for example for tables with headers H1,H2

the expected result from “group by” H1:

Advertisement

Answer

If you’r using array_agg dont forget to use DISTINCT

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement