有人可以建议我如何根据Redshift中的一个特定用户ID将多行合并到一列中。我使用了Listagg函数,但当我在Redshift中将百万行与大小限制错误结合使用时,Listagg会中断。
我一直在使用以下查询,但Listagg超出限制时会中断
SELECT id,
LISTAGG(dest_id, '->')
WITHIN GROUP (ORDER BY arriving_time)
OVER (PARTITION BY ID) AS ROUTES,
CASE
WHEN arriving_time IS NOT NULL
THEN 1
ELSE 0
END AS arrived,
CASE
WHEN departing_time IS NOT NULL
THEN 1
ELSE 0
END AS departed,
row_number()
OVER (PARTITION BY id ORDER BY departing_time)
AS RNK
有人可以建议我更好地实现这一目标。