Hive SQL从多分区选择不同的user_id



这是一个蜂巢表

create table user_log (user_id string, visit_tm bigint) partition by(etl_dt string);
etl_dt >= '2018-01-01' and etl_dt <= '2018-01-30'

每个分区都有很多记录。我想从每个分区中选择100个USER_ID,并且每个user_id彼此都不同。如何写蜂巢SQL?我需要一些帮助。谢谢!

您可以尝试此查询:

select DISTINCT user_id from  user_log where etl_dt >= '2018-01-01' limit 100 UNION select DISTINCT user_id from  user_log where etl_dt <= '2018-01-01' limit 100;

希望此帮助

最新更新