ソースコード




select 
    s.age as AGE,
    case s.gender_code
        when '20' then 'MAIL'
        else 'FEMAIL'
    end as GENDER,
    H_AVG,
    round(cast(sum(iif(category_code='10' and average_value>=h_avg,1,0)) as real)/cast(H_all as real)*100,1) || '%' as H_PER,
    W_AVG,
    round(cast(sum(iif(category_code='20' and average_value>=w_avg,1,0)) as real)/cast(w_all as real)*100,1) || '%' as w_PER 
from school_health as S 

inner join (
select 
     AGE,
     gender_code,
     round(avg(iif(category_code='10',average_value,null)),1) as H_AVG ,
     round(avg(iif(category_code='20',average_value,null)),1) as W_AVG,
     sum(iif(category_code='10',1,0)) as H_ALL,
     sum(iif(category_code='20',1,0)) as W_ALL
from school_health 
where survey_year=2019 
group by gender_code,age ) as A 
on s.age=a.age and s.gender_code=a.gender_code 

where 
    survey_year=2019 
group by s.age,s.gender_code
order by s.age desc,s.gender_code desc; 
 
提出情報
提出日時2023/09/03 19:36:53
コンテスト第8回 SQLコンテスト
問題身長と体重
受験者kate
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量81 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
77 MB
データパターン2
WA
81 MB