Hive失败SemanticException

时间:2017-08-23 09:16:08

标签: hadoop hive hadoop2

Hive vertion:apache-hive-2.3.0
hive> select TAG_EMOTION_KEY AS key,count(1) AS cnn from NB_ORDER_RATE_EMOTION t  where t.cnn>10 group by TAG_EMOTION_KEY ;
FAILED: SemanticException [Error 10002]: Line 1:84 Invalid column reference 'cnn' 

原因是什么?

1 个答案:

答案 0 :(得分:0)

您基本上试图获取出现超过10的TAG_EMOTION_KEY列表。为此,您需要使用HAVING而不是WHERE子句。

像:

select
    TAG_EMOTION_KEY AS key,
    count(1) AS cnn
from
    NB_ORDER_RATE_EMOTION t
group by
    TAG_EMOTION_KEY
having
    count(1) > 10
;

以下问题提供了HAVING& WHERE条款:SQL - having VS where