根据窗口函数过滤行
有没有办法在同一个 select 语句中根据 row_number
上的窗口函数过滤行?
目前,我正在做的是,
SELECT other_columns,row_id_ranked FROM (
SELECT other_columns, "row_number"() OVER (
PARTITION BY "uuid"
ORDER BY "uuid" ASC, "status"."sequence" DESC
) "row_id_ranked",
FROM my_table
)
WHERE row_id_ranked = 1
但这意味着 Presto 将创建一个临时内部表并计算“row_id_ranked”,这意味着额外的工作。
有没有办法过滤掉同一 select 语句中的行? 像这样的东西,
"status"."sequence" FILTER(
WHERE (
"row_number"()
OVER (
PARTITION BY "uuid"
ORDER BY "uuid" ASC,
"status"."sequence" DESC
)
) = 1
) "sequence_num",
Is there a way to filter out rows based on a a window function over row_number
in the same select statement?
Currently, what I'm doing is,
SELECT other_columns,row_id_ranked FROM (
SELECT other_columns, "row_number"() OVER (
PARTITION BY "uuid"
ORDER BY "uuid" ASC, "status"."sequence" DESC
) "row_id_ranked",
FROM my_table
)
WHERE row_id_ranked = 1
But this means Presto will create a temporary inner table to and calculate the "row_id_ranked", which means extra work.
is there a way to filter out the rows within the same select statement?
Something like,
"status"."sequence" FILTER(
WHERE (
"row_number"()
OVER (
PARTITION BY "uuid"
ORDER BY "uuid" ASC,
"status"."sequence" DESC
)
) = 1
) "sequence_num",
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论