I have a problem with STRING_AGG in Bigquery. I'm trying:
SELECT
id,
institution,
COUNT(DISTINCT institution) OVER (PARTITION BY id) as count_intitution
STRING_AGG(DISTINCT institution,"," ) OVER (PARTITION BY id) as list_intitution
FROM
name_table
WHERE
DATE(created_at) = "2020-02-02"
and i get this error:
Analytic function string_agg does not support DISTINCT.
BQ documentation says it allows the use of "DISTINCT"
https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#string_agg
But apparently it doesn't support "partition by", why?
EDIT:
the current table is like this (it is an example, the table has more attributes)
|id |institution|
|1 | a |
|1 | b |
|2 | a |
|2 | c |
|3 | a |
|1 | a |
and what I want to achieve is
|id|count_institution|list_institution|
|1 |2 |a,b |
|2 |2 |a,c |
|3 |1 |a |