首页 > 解决方案 > 雅典娜 - 案例陈述计数

问题描述

尝试在 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)

任何帮助表示赞赏。谢谢!

标签: sqlamazon-web-servicesprestoamazon-athena

解决方案


您应该在第一次计数后添加逗号,使用 count 也会为所有记录提供相同的计数,您应该使用 sum


推荐阅读