コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
SELECT DISTINCT B1.AGE,
(CASE WHEN B1.GENDER_CODE = '20' THEN 'MALE'
ELSE 'FEMALE'
END) AS GENDER,
H_AB.H_AVG,
H_AB.H_PER,
W_AB.W_AVG,
W_AB.W_PER
FROM SCHOOL_HEALTH B1 INNER JOIN (
SELECT BASE.AGE,
BASE.GENDER_CODE,
H1.H_AVG,
CAST(ROUND(COUNT(*) / CAST(H1.CNT AS REAL) * 100,1) AS TEXT) || "%" AS H_PER
FROM SCHOOL_HEALTH BASE INNER JOIN (SELECT DISTINCT SH.AGE,
SH.GENDER_CODE,
H.H_AVG,
PF_CNT.CNT
FROM SCHOOL_HEALTH SH 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
) H
ON SH.AGE = H.AGE
AND SH.GENDER_CODE = H.GENDER_CODE
INNER JOIN (SELECT AGE,
GENDER_CODE,
COUNT(*) AS CNT
FROM SCHOOL_HEALTH
WHERE SURVEY_YEAR = 2019
AND CATEGORY_CODE = '10'
GROUP BY AGE,
GENDER_CODE
) PF_CNT
ON SH.AGE = PF_CNT.AGE
AND SH.GENDER_CODE = PF_CNT.GENDER_CODE
WHERE SURVEY_YEAR = 2019
) H1
ON BASE.AGE = H1.AGE
AND BASE.GENDER_CODE = H1.GENDER_CODE
WHERE BASE.SURVEY_YEAR = 2019
AND BASE.CATEGORY_CODE = '10'
AND BASE.AVERAGE_VALUE >= H1.H_AVG
GROUP BY BASE.AGE,
BASE.GENDER_CODE,
H1.H_AVG,
H1.CNT
) H_AB
ON B1.AGE = H_AB.AGE
AND B1.GENDER_CODE = H_AB.GENDER_CODE
INNER JOIN (
SELECT BASE.AGE,
BASE.GENDER_CODE,
H1.H_AVG AS W_AVG,
CAST(ROUND(COUNT(*) / CAST(H1.CNT AS REAL) * 100,1) AS TEXT) || "%" AS W_PER
FROM SCHOOL_HEALTH BASE INNER JOIN (SELECT DISTINCT SH.AGE,
SH.GENDER_CODE,
H.H_AVG,
PF_CNT.CNT
FROM SCHOOL_HEALTH SH INNER JOIN (SELECT AGE,
GENDER_CODE,
ROUND(AVG(AVERAGE_VALUE),1) AS H_AVG
FROM SCHOOL_HEALTH
WHERE SURVEY_YEAR = 2019
AND CATEGORY_CODE = '20'
GROUP BY AGE,
GENDER_CODE
) H
ON SH.AGE = H.AGE
AND SH.GENDER_CODE = H.GENDER_CODE
INNER JOIN (SELECT AGE,
GENDER_CODE,
COUNT(*) AS CNT
FROM SCHOOL_HEALTH
WHERE SURVEY_YEAR = 2019
AND CATEGORY_CODE = '20'
GROUP BY AGE,
GENDER_CODE
) PF_CNT
ON SH.AGE = PF_CNT.AGE
AND SH.GENDER_CODE = PF_CNT.GENDER_CODE
WHERE SURVEY_YEAR = 2019
) H1
ON BASE.AGE = H1.AGE
AND BASE.GENDER_CODE = H1.GENDER_CODE
WHERE BASE.SURVEY_YEAR = 2019
AND BASE.CATEGORY_CODE = '20'
AND BASE.AVERAGE_VALUE >= H1.H_AVG
GROUP BY BASE.AGE,
BASE.GENDER_CODE,
H1.H_AVG,
H1.CNT
) W_AB
ON B1.AGE = W_AB.AGE
AND B1.GENDER_CODE = W_AB.GENDER_CODE
ORDER BY B1.AGE DESC,B1.GENDER_CODE DESC
提出情報
提出日時 | 2023/08/20 21:46:35 |
コンテスト | 第8回 SQLコンテスト |
問題 | 身長と体重 |
受験者 | yng |
状態 (詳細) | AC (Accepted: 正答) |
メモリ使用量 | 83 MB |
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
80 MB
データパターン2
AC
83 MB