ソースコード
SELECT
	SUM_AMT.PF_CODE AS CODE,
	P.PF_NAME  AS NAME,
	ROUND(CAST(SUM_DRINK.D_AMT AS REAL) / CAST(SUM_AMT.AMT AS REAL) * 100.0, 1) AS PERCENTAGE
FROM
	(SELECT PF_CODE, SUM(AMT) AS AMT  FROM DRINK_HABITS WHERE GENDER_CODE IN ('2', '3') AND CATEGORY_CODE = '110' GROUP BY PF_CODE) AS SUM_AMT
	LEFT JOIN 
	(SELECT PF_CODE, SUM(AMT) AS D_AMT FROM DRINK_HABITS WHERE GENDER_CODE IN ('2', '3') AND CATEGORY_CODE = '120' GROUP BY PF_CODE) AS SUM_DRINK
	ON SUM_AMT.PF_CODE = SUM_DRINK.PF_CODE
	LEFT JOIN PREFECTURE P
	ON SUM_AMT.PF_CODE = P.PF_CODE
ORDER BY
	PERCENTAGE DESC,
	CODE DESC
提出情報
提出日時2022/09/21 16:42:39
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者tanaka
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量100 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
100 MB
データパターン2
AC
99 MB