ソースコード
SELECT
	SH.AGE
,   CASE WHEN SH.GENDER_CODE = '30' THEN 'FEMALE' ELSE 'MALE' END GENDER
,   ROUND(H_AVG.H_AVG,1) H_AVG
,	ROUND(CAST(SUM(CASE WHEN SH.AVERAGE_VALUE >= H_AVG.H_AVG THEN 1 ELSE 0 END) AS REAL) / COUNT(*) * 100 ,1) || '%' H_PER
,   ROUND(W_AVG.W_AVG,1) W_AVG
,	ROUND(CAST(SUM(CASE WHEN SH.AVERAGE_VALUE >= W_AVG.W_AVG THEN 1 ELSE 0 END) AS REAL) / COUNT(*) * 100 ,1) || '%' W_PER
FROM
	SCHOOL_HEALTH SH
INNER JOIN
	(SELECT
	AGE, GENDER_CODE, AVG(AVERAGE_VALUE) H_AVG
	FROM
	SCHOOL_HEALTH
	WHERE
	CATEGORY_CODE = '10'
	GROUP BY
	AGE, GENDER_CODE) AS H_AVG
ON
	SH.AGE = H_AVG.AGE
	AND SH.GENDER_CODE = H_AVG.GENDER_CODE
INNER JOIN
	(SELECT
	AGE, GENDER_CODE, AVG(AVERAGE_VALUE) W_AVG
	FROM
	SCHOOL_HEALTH
	WHERE
	CATEGORY_CODE = '20'
	GROUP BY
	AGE, GENDER_CODE) AS W_AVG
ON
	SH.AGE = W_AVG.AGE
	AND SH.GENDER_CODE = W_AVG.GENDER_CODE
GROUP BY
	SH.AGE, SH.GENDER_CODE
ORDER BY
    SH.AGE DESC, SH.GENDER_CODE DESC
提出情報
提出日時2023/08/21 11:20:18
コンテスト第8回 SQLコンテスト
問題身長と体重
受験者awageppo
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量99 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
99 MB
データパターン2
WA
99 MB