ソースコード
WITH DRINKER AS (
SELECT
    PF_CODE
    , TOTAL(AMT) AS DRINKER_COUNT
FROM
    DRINK_HABITS
WHERE
    CATEGORY_CODE = '120'
    AND GENDER_CODE IN ('2','3')
GROUP BY
    PF_CODE
) , RESIDENTS AS (
SELECT
    PF_CODE
    , TOTAL(AMT) AS RESIDENTS_COUNT
FROM
    DRINK_HABITS
WHERE
    CATEGORY_CODE = '110'
GROUP BY
    PF_CODE
) 
SELECT
    D.PF_CODE AS CODE
    , PF_NAME AS NAME
    , ROUND(DRINKER_COUNT/RESIDENTS_COUNT*100 , 1) AS PERCENTAGE
FROM
    DRINKER D
    INNER JOIN
        RESIDENTS R ON D.PF_CODE = R.PF_CODE
    INNER JOIN
        PREFECTURE P ON D.PF_CODE = P.PF_CODE
ORDER BY
    PERCENTAGE DESC
    , D.PF_CODE DESC
;
提出情報
提出日時2022/09/22 10:27:03
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者toridashisoba
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量101 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
101 MB
データパターン2
AC
100 MB