hive semi and having 例子

  • hive中left semi join相当于SQL中的where in语句
  • having语句用于在group by中对每组数据进行where条件限制
select * from user_action_201704 y 
left semi join 
(select userid as xuserid,count(*) as count 
from user_action_201704 
where day="04" 
and city="5000" 
group by userid 
having count(*)<= 6 ) x 
on y.userid=x.xuserid 
where y.day="04" 
order by y.userid,substring(y.action,1,20);

你可能感兴趣的:(hive semi and having 例子)