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