Google bigquery 基于其他SELECT参数的不平等性基础SQL

Google bigquery 基于其他SELECT参数的不平等性基础SQL,google-bigquery,Google Bigquery,这是在大查询中执行基于级联不等式的SQL约束。 date1用作中间参数 Select id, date, date1 From table1 Where date > date1 AND date1 in ( select dateref from table2) 循环版本: For all date1 in (select dateref from table2) : select id, date, date1 from table1

这是在大查询中执行基于级联不等式的SQL约束。 date1用作中间参数

Select  id, date, date1
 From   table1
 Where  date > date1  
        AND date1 in ( select dateref from table2)
循环版本:

For all date1 in (select dateref from table2) :
   select id, date, date1
   from table1 
   where date > date1

一个特殊的案例解决方案,以防其他人寻找。 如果两个表共享相同的id,则可以使用JOIN来对齐它们

select  same_id, date1,  dateref 

from ( 
   select   g1.same_id,  date1,  g2.dateref  
   from   `log2*`   as g1
   JOIN
      (  
        select  dateref,
          from `log1*`
          WHERE _TABLE_SUFFIX BETWEEN '20170101' AND '20170630'
      )   as g2
      ON   g1.same_id = g2.same_id  


where
     _TABLE_SUFFIX BETWEEN '20170101' AND '20170630'
)
where 
      date1 > dateref