Google bigquery bigquery lead窗口函数有没有办法使用表值作为偏移量?
我想知道bigquery标准sql中的lead window函数是否存在使用表值而不是文本或查询参数的解决方法Google bigquery bigquery lead窗口函数有没有办法使用表值作为偏移量?,google-bigquery,Google Bigquery,我想知道bigquery标准sql中的lead window函数是否存在使用表值而不是文本或查询参数的解决方法 select artcl ,days ,lead(days,ofst)over(partition by artcl order by days) as tst from( select 123 as artcl, 1 as days ,2 as ofst union all select 123 as artcl, 2 as days ,2 as ofst
select
artcl
,days
,lead(days,ofst)over(partition by artcl order by days) as tst
from(
select 123 as artcl, 1 as days ,2 as ofst
union all
select 123 as artcl, 2 as days ,2 as ofst
union all
select 123 as artcl, 3 as days ,2 as ofst
)
你可以使用下面的方法
select artcl, days, ofst,
arr[safe_offset(row_number() over(partition by artcl order by days) + ofst - 1)] as tst
from `project.dataset.table`
join (
select artcl, array_agg(days order by days) arr,
from `project.dataset.table`
group by artcl
)
using(artcl)
考虑一下,也可以帮助回答这个问题。