ソースコード
WITH H2019 AS (
SELECT * FROM SCHOOL_HEALTH WHERE SURVEY_YEAR = 2019
),
-- 身長

H AS (
SELECT AGE, CASE GENDER_CODE WHEN '20' THEN 'MALE' WHEN '30' THEN 'FEMALE' END AS GENDER, AVERAGE_VALUE FROM H2019
WHERE CATEGORY_CODE = '10'
),
-- 体重
W AS (
SELECT AGE, CASE GENDER_CODE WHEN '20' THEN 'MALE' WHEN '30' THEN 'FEMALE' END AS GENDER, AVERAGE_VALUE FROM H2019
WHERE CATEGORY_CODE = '20'
),
H_AV AS (
SELECT AGE, GENDER, AVG(AVERAGE_VALUE) AS HAV FROM H
GROUP BY AGE, GENDER
)

SELECT AGE, GENDER, HAV AS H_AVG, (COUNT(HAV <= H.AVERAGE_VALUE OR NULL)/COUNT(*)) AS H_PER
FROM H NATURAL JOIN H_AV
GROUP BY AGE, GENDER
提出情報
提出日時2023/08/21 10:56:11
コンテスト第8回 SQLコンテスト
問題身長と体重
受験者nadia
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量99 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
99 MB
データパターン2
WA
98 MB