在 GTE 或 LTE 条件下执行左连接的替代方法是什么?
What is alternative to performing a left join on GTE or LTE conditions?
我需要使用特定的旧版本 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
这个的替代查询是什么?
另一种方法是将条件的 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
我需要使用特定的旧版本 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
这个的替代查询是什么?
另一种方法是将条件的 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