hive - 如何计算配置单元分区表中的值
问题描述
我有一个有 2 列的分区表,(country,status)
现在我想计算列中的次数SUCCESS
和ERROR
次数status
。我该如何解决这个问题?
解决方案
具有聚合的用例语句:
select country,
sum(case when status='SUCCESS' then 1 end) cnt_SUCCESS,
sum(case when status='ERROR' then 1 end) cnt_ERROR
from tablename
group by country;
如果您需要总计数,请group by country
删除并列。country
推荐阅读
- angular - Angular 6 中 ng2-file-upload 的进度条
- css - 减轻另一个类的背景颜色
- javascript - 使用 Selenium JavaScript 上传图片
- c - C:如果我一次发送少于 6 个字节,Curl 不接收字节
- android - 无法发布 APK React Native Android 应用
- python - 如何使用 Django 模板作为组件?
- ios - 在设备上记录数据并从远程设备检索日志
- java - CentOS7 中的 Java webapp 无法连接到 MSSQL 服务器
- php - FIND_IN_SET in cakephp not working
- c# - Spinner 未以模式显示异步函数 c#