sql - 雅典娜 - 案例陈述计数
问题描述
尝试在 AWS Athena 中执行以下操作。这对我来说似乎是标准 SQL:
select
count(case when gender='Male' then 1 end) as male_count
count(case when gender='Female' then 1 end) as female_count,
count(case when gender is null then 1 end) as other_count,
count(*) as total_count
from onepercentsampleflattened_90days_parquet;
我收到以下错误:
line 3:3: mismatched input 'count' expecting {<eof>, ',', 'from', 'where', 'group', 'order', 'having', 'limit', 'union', 'except', 'intersect'} (service: amazonathena; status code: 400; error code: invalidrequestexception; request id: d7ccbaef-e5da-4fca-8ae8-60fb8b93ce6c)
任何帮助表示赞赏。谢谢!
解决方案
您应该在第一次计数后添加逗号,使用 count 也会为所有记录提供相同的计数,您应该使用 sum
推荐阅读
- javascript - 如何将 Stack 的编辑器正确集成到我的网站中?
- c++ - 没有错误但程序没有启动
- c# - 从 Oracle DB 获取今天的数据
- apache-spark - 'replaceWhere' 会导致删除吗?
- c++ - 通常一个函数不能访问另一个函数中定义的变量
- elasticsearch - 在 Elastic 中搜索多个索引时限制每个索引的大小
- node.js - 在 react native 中使用自定义后端验证 oauth 用户
- python - 如何在特定字符之前从字符串中删除特殊字符?
- pascal - 帕斯卡。为调用“f1”指定的参数数量错误
- node.js - 如何使用 $filter 从嵌套数组中检索结果?