ソースコード
with t as (
select 
AGE,
GENDER_CODE,
case gender_code when 20 then 'MALE' when '30' then 'FEMALE' end as GENDER,
round(avg(case when category_code = 10 then average_value end), 1) H,
round(avg(case when category_code = 20 then average_value end), 1) W
from school_health
where survey_year=2019
group by 1,2,3
)


select t.AGE, t.GENDER, 
t.H as H_AVG, 
round(avg(case when category_code = 10 and s.average_value >= t.H then 100
  when category_code = 10 then 0 else null end), 1) || '%' as H_PER,

t.W as W_AVG, 
round(avg(case when category_code = 20 and s.average_value >= t.W then 100
  when category_code = 20 then 0 else null end), 1) || '%' as W_PER
from school_health s
inner join t on t.AGE = s.AGE and t.GENDER_CODE = s.GENDER_CODE
group by 1,2
order by 1 desc, t.gender_code desc
提出情報
提出日時2023/08/20 22:07:05
コンテスト第8回 SQLコンテスト
問題身長と体重
受験者sh_yama
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量81 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
79 MB
データパターン2
WA
81 MB