如果指定了DISTINCT,则不允许BigQuery窗口使用ORDER BY [英] BigQuery Window ORDER BY is not allowed if DISTINCT is specified
问题描述
我正在调查移植一些像这样的窗口化不同计数的bigquery传统sql
I'm investigating porting some bigquery legacy sql containing windowed distinct counts like this
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 ....,但出现此错误....
to Standard sql.... but I get this error....
Window ORDER BY is not allowed if DISTINCT is specified
作为参考,我尝试了APPROX_COUNT_DISTINCT
函数,但是没有运气.
For reference I've tried APPROX_COUNT_DISTINCT
function with no luck.
除了编写子查询和分组依据之外,还有其他更好的方法可以使它工作吗?
Is there a better way to get this to work other than write the subqueries and group by's?
大多数其他查询只进行了很小的更改就移植到了标准sql.
Most of the other queries have ported to standard sql with only minor changes.