查询重复值并根据它们选择列值

rta7y2nd  于 2021-06-27  发布在  Hive
关注(0)|答案(1)|浏览(279)


我需要从表test中提取数字,表test有两个以上的区域类型,并且有area=“three”作为值。我应该得到结果“b”和“f”。
谢谢您。

ev7lccsx

ev7lccsx1#

以下是查询-

select count(*), number from <tableName> where number in (select number from <tableName> where area='three') group by number having count(*)>1;

select number from <tableName> group by number having count(*)>1 and sum(case when area='Three' then 1 else 0) = 1;

相关问题