受Masashi启发,此解决方案更简单,并且可以从Redshift中从一组中选择一个随机元素。
SELECt id, first_value as attribute FROM(SELECt id, FIRST_VALUE(attribute) OVER(PARTITION BY id ORDER BY random() ROWS BETWEEN unbounded preceding AND unbounded following) FROM dataset) GROUP BY id, attribute ORDER BY id;


![Amazon Redshift机制,用于将列聚合为字符串[重复] Amazon Redshift机制,用于将列聚合为字符串[重复]](http://www.mshxw.com/aiimages/31/517280.png)
