Pick a random attribute from group in Redshift

后端 未结 4 1498
攒了一身酷
攒了一身酷 2021-01-23 04:37

I have a data set in the form.

id  |   attribute
-----------------
1   |   a
2   |   b
2   |   a
2   |   a
3   |   c

Desired output:

4条回答
  •  别那么骄傲
    2021-01-23 05:03

    I haven't tested this query, but these functions are supported in Redshift:

    select id, arrary_to_string(array(select attribute from mydataset m where m.id=d.id),',') from mydataset d

提交回复
热议问题