Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想返回一个组的前 5 行。基本上我有一个表格,上面有一些州名和他们的城市,按州名分组。我想拥有该州排名前 5 的城市,而不是所有城市。
我怎么能用猪来做到这一点?先感谢您。
在 a 之后GROUP BY,在 a FOREACH... 中你可以先做一个ORDER BY,然后LIMIT。这将首先按城市大小对每个组中的事物进行排序,然后拉出前 5 名。
GROUP BY
FOREACH
ORDER BY
LIMIT
B = GROUP A BY state; C = FOREACH B { DA = ORDER A BY citysize DESC; DB = LIMIT DA 5; GENERATE FLATTEN(group), FLATTEN(DB.citysize), FLATTEN(DB.cityname); }