我需要使用特定的旧版HIVE,以防止我在GTE或LTE条件下加入2个表格。例如,
的等价物select *
from table1 as t1
left join table2 as t2
on t1.id = t2.id
and (t1.date >= t2.date and t1.date <= t2.date+7) -- i can no longer do this condition
对此有什么替代查询?
答案 0 :(得分:2)
另一种方法是将GTE / LTE部分条件移到where
子句中,该子句将在作为过滤器加入后应用:
select *
from table1 as t1
left join table2 as t2 on t1.id = t2.id
where (t1.date >= t2.date and t1.date <= date_add(t2.date,7))
or t2.id is null