ソースコード
SELECT
     MAIN.PF_CODE AS CODE
    ,P.PF_NAME AS NAME
    ,ROUND(MAIN.AMT * 100.0 / SUB.AMT, 1) AS PERCENTAGE
FROM
(
    SELECT
         PF_CODE
        ,SUM(AMT) AS AMT
    FROM
        DRINK_HABITS
    WHERE
        CATEGORY_CODE='120'
    AND GENDER_CODE IN ('2','3')
    GROUP BY
        PF_CODE
) AS MAIN

INNER JOIN
(
    SELECT
         PF_CODE
        ,SUM(AMT) AS AMT
    FROM
        DRINK_HABITS
    WHERE
        CATEGORY_CODE='110'
    AND GENDER_CODE IN ('2','3')
    GROUP BY
        PF_CODE
) AS SUB
ON
    SUB.PF_CODE = MAIN.PF_CODE
    
INNER JOIN
    PREFECTURE AS P
ON
    P.PF_CODE = MAIN.PF_CODE
    
ORDER BY
     ROUND(MAIN.AMT * 100.0 / SUB.AMT, 1) DESC
    ,MAIN.PF_CODE DESC
提出情報
提出日時2024/02/15 00:15:43
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者mo
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
82 MB