ソースコード
SELECT
    PREF.PF_CODE AS CODE,
    PREF.PF_NAME AS NAME,
    ROUND((CAST(DRINK.AMT AS DOUBLE) / CAST(POP.AMT AS DOUBLE))*100, 1) AS PERCENTAGE
FROM
    PREFECTURE PREF
INNER JOIN
    (
        SELECT  
            PF_CODE,
            SUM(AMT) AS AMT
        FROM
            DRINK_HABITS
        WHERE
            GENDER_CODE IN ('2','3')
        AND
            CATEGORY_CODE = '110'
        GROUP BY
        PF_CODE
    ) POP
ON PREF.PF_CODE = POP.PF_CODE
INNER JOIN
	(
		SELECT  
            PF_CODE,
            SUM(AMT) AS AMT
        FROM
            DRINK_HABITS
        WHERE
            GENDER_CODE IN ('2','3')
        AND
            CATEGORY_CODE = '120'
        GROUP BY
        PF_CODE
    ) DRINK
ON PREF.PF_CODE = DRINK.PF_CODE
GROUP BY
    PREF.PF_CODE,
    PREF.PF_NAME
ORDER BY
    ROUND((CAST(DRINK.AMT AS DOUBLE) / CAST(POP.AMT AS DOUBLE))*100, 2) desc,
    PREF.PF_CODE desc
;
提出情報
提出日時2022/09/22 12:20:13
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者MMpine
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量99 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
WA
99 MB
データパターン2
AC
97 MB