Hive 过滤器计数(*)超过某个数字?

Hive 过滤器计数(*)超过某个数字?,hive,count,where,Hive,Count,Where,如果我尝试运行以下任一查询,则会收到消息: 编译语句时出错:失败:ParseException行5:0 “nino_dtkn”附近的“where”缺少EOF 这表明我不能在同一个查询中使用新创建的count变量 我的结论正确吗 我能做些什么来修复它 我不想创建一个新表——我想用它作为子查询合并到第二个表上 select count(*) as cnt, [variable 1] from [source table] group by [variable

如果我尝试运行以下任一查询,则会收到消息:

编译语句时出错:失败:ParseException行5:0 “nino_dtkn”附近的“where”缺少EOF

这表明我不能在同一个查询中使用新创建的count变量

我的结论正确吗

我能做些什么来修复它

我不想创建一个新表——我想用它作为子查询合并到第二个表上

select count(*) as cnt, 
                   [variable 1]
from [source table]
group by [variable 1]
where count(*) >= 20; 

select count(*) as cnt, 
                   [variable 1]
from [source table]
group by [variable 1]
where cnt >= 20;
使用子句


我不确定你的预期结果<代码>WHERE子句应始终位于
按函数分组
之前

因此,您的查询可以重写为下面提到的查询:

select count(*) as cnt,[variable 1]
from [source table]
where count(*) >= 20
group by [variable 1]
; 

谢谢你,VK,非常感谢你的机敏和智慧!我试过了,但是:“谢谢你的反馈!声誉低于15的人所投的票会被记录下来,但不会改变公开显示的帖子分数。”是的,要在聚合上添加条件,请使用having子句!:-)
select count(*) as cnt,[variable 1]
from [source table]
where count(*) >= 20
group by [variable 1]
;