簡體   English   中英

雅典娜 - 案例陳述計數

[英]Athena - count of case statement

嘗試在 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM