我在配置单元中有以下数据:
userid cityid
1 15
2 15
1 7
3 15
2 8
3 9
3 7
我只想保留具有 cityid 15 和 cityid 7 的用户 ID(在我的示例中,它将是用户 ID 1 和 3)。 我尝试过:
select userid from table where cityid = 15 and userid in (select userid from table where cityid = 7);
但是对于 hive 它不起作用。 有人可以帮忙吗?
谢谢!
最佳答案
好的,我找到了该怎么做:
select a.userid from (select userid from table where cityid = 15) a join (select userid from table where cityid = 7) b on a.userid = b.userid;
关于hive - 在 Hive 中获取数据的交集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13306593/