Sql 使用日期条件连接两个表

Sql 使用日期条件连接两个表,sql,google-bigquery,Sql,Google Bigquery,我在Biquery上有两个事实表,如果datestart介于dateCreate和dateCreate+10之间,我想使用id连接它们 表A 身份证件 日期创建 名称 2548 2020-02-05 史密斯 6005 2020-03-02 保罗 5485 2020-03-02 米奇 5435 2020-02-04 南希 2485 2020-07-05 米洛 2285 2020-12-06 杰尼夫 这行吗 select a.* from a left join b on b.i

我在Biquery上有两个事实表,如果datestart介于dateCreate和dateCreate+10之间,我想使用id连接它们

表A

身份证件 日期创建 名称 2548 2020-02-05 史密斯 6005 2020-03-02 保罗 5485 2020-03-02 米奇 5435 2020-02-04 南希 2485 2020-07-05 米洛 2285 2020-12-06 杰尼夫 这行吗

select a.*
from a left join
     b
     on b.id2 = a.id and
        b.datestart > a.dateCreate and
        b.datestart < date_add(a.dateCreate, interval 10 day);
BigQuery有时在使用非Equijoin时会出现问题,但我认为这会起作用