gpt4 book ai didi

google-bigquery - BigQuery select 语句别名在 where 子句中不起作用

转载 作者:行者123 更新时间:2023-12-05 09:13:00 27 4
gpt4 key购买 nike

我尝试了下面给出的查询,但它抛出错误 RANK is not defined。

SELECT
EmailAddress
, FirstName
, LastName
, RANK() OVER (ORDER BY BookingDate) AS RANK FROM `table_name`
WHERE RANK BETWEEN 5 AND 7

最佳答案

以下是 BigQuery 标准 SQL

WHERE 子句在形成查询输出并分配别名之前进行评估,这意味着字段 rankWHERE rank BETWEEN 5 AND 7 时不可用。

你只需要在下面使用

#standardSQL
SELECT * FROM (
SELECT
EmailAddress
, FirstName
, LastName
, RANK() OVER (ORDER BY BookingDate) AS rank
FROM `project.dataset.table`
)
WHERE rank BETWEEN 5 AND 7

关于google-bigquery - BigQuery select 语句别名在 where 子句中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56986714/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com