语句1:

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

会出现错误:

hive中having 后面count(xx) 条件的问题_having

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

如果我们不使用去重的关键字, 就是可以运行的

语句2:

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

hive中having 后面count(xx) 条件的问题_having_02