コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
WITH HEIGHT_TBL AS (
SELECT S.AGE,
S.GENDER_CODE,
H_AVG AS H_AVG,
ROUND(100.0 * SUM(CASE WHEN AVERAGE_VALUE >= H_AVG THEN 1 ELSE 0 END) / COUNT(*), 1) || "%" AS H_PER
FROM SCHOOL_HEALTH AS S INNER JOIN (
SELECT AGE, GENDER_CODE, ROUND(AVG(AVERAGE_VALUE), 1) AS H_AVG
FROM SCHOOL_HEALTH
WHERE SURVEY_YEAR = 2019
AND CATEGORY_CODE = "10"
GROUP BY AGE, GENDER_CODE
) AS H
ON S.AGE = H.AGE AND S.GENDER_CODE = H.GENDER_CODE
WHERE SURVEY_YEAR = 2019 AND CATEGORY_CODE = "10"
GROUP BY S.AGE, S.GENDER_CODE
),
WEIGHT_TBL AS (
SELECT S.AGE,
S.GENDER_CODE,
ROUND(W_AVG, 1) AS W_AVG,
ROUND(100.0 * SUM(CASE WHEN AVERAGE_VALUE >= W_AVG THEN 1 ELSE 0 END) / COUNT(*), 1) || "%" AS W_PER
FROM SCHOOL_HEALTH AS S INNER JOIN (
SELECT AGE, GENDER_CODE, ROUND(AVG(AVERAGE_VALUE), 1) AS W_AVG
FROM SCHOOL_HEALTH
WHERE SURVEY_YEAR = 2019
AND CATEGORY_CODE = "20"
GROUP BY AGE, GENDER_CODE
) AS W
ON S.AGE = W.AGE AND S.GENDER_CODE = W.GENDER_CODE
WHERE SURVEY_YEAR = 2019 AND CATEGORY_CODE = "20"
GROUP BY S.AGE, S.GENDER_CODE
)
SELECT H.AGE,
CASE WHEN H.GENDER_CODE = "20" THEN "MALE" ELSE "FEMALE" END AS GENDER,
H_AVG,
H_PER,
W_AVG,
W_PER
FROM HEIGHT_TBL AS H INNER JOIN WEIGHT_TBL AS W ON H.AGE = W.AGE AND H.GENDER_CODE = W.GENDER_CODE
ORDER BY H.AGE DESC, H.GENDER_CODE DESC
提出情報
提出日時 | 2023/09/23 02:48:25 |
コンテスト | 第8回 SQLコンテスト |
問題 | 身長と体重 |
受験者 | Haar |
状態 (詳細) | AC (Accepted: 正答) |
メモリ使用量 | 81 MB |
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
77 MB
データパターン2
AC
81 MB