首页 > 解决方案 > 过滤计数(*)超过一定数量?

问题描述

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

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

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

我的结论正确吗?

我能做些什么来修复它?

我不想创建一个新表 - 我想将其用作子查询以合并到第二个表。

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;

标签: hivecountwhere

解决方案


使用HAVING子句

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

推荐阅读