hive - 过滤计数(*)超过一定数量?
问题描述
如果我尝试运行以下任一查询,则会收到以下消息:
编译语句时出错:失败: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;
解决方案
使用HAVING子句
select count(*) as cnt,[variable 1]
from [source table]
group by [variable 1]
having count(*) >= 20;
推荐阅读
- r - 合并来自不同数据框的同一列
- ngx-bootstrap - 构建或运行 ngx-bootstrap 测试时出错
- visual-studio-code - 如何使可变自定义数据可用于自定义扩展?
- c++ - 在别人提交任务的前提下,如何在集群上使用多个gpus?
- python - 如何按日期创建一个文件夹并将文件放入其中?
- apache-kafka - Kafka,commitSync 成功
- angular - 为什么 TranslateService Angular 不会将当前语言添加到 localStorage?
- django - Django - 使用子查询更新
- javascript - 数组 indexOf() 和字符串 indexOf() 之间的差异导致版本问题
- tsql - 在 SQL Anywhere 上找不到相关名称