我在表格中有2列。让我们将它们称为A列和B列。我想找到A,其中B的非重复数大于1.在SQL中
select column_a
from table1
group by column_a
having count(distinct column_b) > 1;
出于某种原因,这不适用于HIVE。错误继续说
error while compiling statement: failed: semanticexception [error 10002]: line 4:22 invalid column reference 'column_b'
答案 0 :(得分:1)
你在运行什么版本的Hive?我想这个版本会很好用:
select column_a
from (select column_a, count(distinct column_b) as cnt
from table1
group by column_a
) a
having cnt > 1;
答案 1 :(得分:0)
我终于使用
开始工作了select column_a, count(distinct column_b)
from table1
group by column_a
having count(distinct column_b) > 1
谢谢戈登