The problem of count (XX) condition after having in hive

chnhbhndchngn 2022-02-13 08:24:52 阅读数:322

problem count xx condition having

sentence 1:

select
user_name
from
user_trade
where
year(dt) = '2018'
group by
user_name
having
count(distinct goods_category) > 2;

There will be errors :

FAILED: SemanticException [Error 10002]: Line 10:19 Invalid column reference 'goods_category'

If we don't use de duplication keywords , It can run

sentence 2:

select
user_name
from
user_trade
where
year(dt) = '2018'
group by
user_name
having
count(goods_category) > 2;

 

copyright:author[chnhbhndchngn],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130824499015.html