考虑sql语句:
SELECT key, value
FROM (
SELECT key, value, row_number() OVER (PARTITION BY key ORDER BY length(value) DESC) AS rn
FROM my_table
)
WHERE rn <= 5;
这将产生:
key value
A 1
A 2
B 10
如何使其成为:
key values
A [1;2;3;4;5]
B [10;20;30;40;50]
sql引擎是presto。有什么想法吗?
1条答案
按热度按时间oipij1gg1#
map_agg
解决方案是:非常感谢,@shantanu kher最快的回复!