我尝试在下面的查询中给出,但是它抛出错误RANK尚未定义。
SELECT
EmailAddress
, FirstName
, LastName
, RANK() OVER (ORDER BY BookingDate) AS RANK FROM `table_name`
WHERE RANK BETWEEN 5 AND 7
答案 0 :(得分:3)
以下是用于BigQuery标准SQL
在形成查询输出并分配别名之前先评估WHERE子句,这意味着rank
时字段WHERE 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