如何在hive中编写以下mysql查询?

时间:2015-07-01 09:39:34

标签: hive

MySQL查询:

select * from user_balance_table  a where report_date < 20130901 and a.user_id not in (select user_id from user_balance_table  a where report_date <20130801);

如何在hive中编写相同的查询?

1 个答案:

答案 0 :(得分:0)

select a.*
from
  (select * from user_balance_table
  where report_date < 20130901
  ) a           
  left outer join
  (select user_id 
  from user_balance_table  
  where report_date <20130801
  group by user_id
  ) b
on a.user_id=b.user_id and b.user_id is null;