小编Sco*_*age的帖子

如果指定了DISTINCT,则不允许BigQuery窗口使用ORDER BY

我正在调查移植一些像这样的窗口化不同计数的bigquery传统sql

count(distinct brand_id) over (partition by user_id order by order_placed_at range between 7 * 24 * 60 * 60 * 1000000 PRECEDING AND 1 PRECEDING) as last_7_day_buyer_brands

到标准SQL。...但是我得到这个错误。

Window ORDER BY is not allowed if DISTINCT is specified

作为参考,我尝试过APPROX_COUNT_DISTINCT没有运气的函数。

除了编写子查询和分组依据以外,还有其他更好的方法可以使它工作吗?

其他大多数查询只进行了少量更改就移植到了标准sql。

window-functions google-bigquery bigquery-standard-sql

1
推荐指数
1
解决办法
725
查看次数