ソースコード
SELECT
    TOTAL.PF_CODE AS CODE
    , PF_NAME AS NAME
    , ROUND(
        CAST(DRINK_AMT AS REAL) * 100 / CAST(TOTAL_AMT AS REAL)
        , 1
    ) AS PERCENTAGE
FROM
(
    SELECT
        PF_CODE
        , SUM(AMT) AS TOTAL_AMT
    FROM
        DRINK_HABITS
    WHERE
        CATEGORY_CODE = '110'
        AND GENDER_CODE != '1'
    GROUP BY
        PF_CODE
) AS TOTAL
INNER JOIN
(
    SELECT
        PF_CODE
        , SUM(AMT) AS DRINK_AMT
    FROM
        DRINK_HABITS
    WHERE
        CATEGORY_CODE = '120'
        AND GENDER_CODE != '1'
    GROUP BY
        PF_CODE
) AS DRINK
ON TOTAL.PF_CODE = DRINK.PF_CODE
INNER JOIN PREFECTURE
    ON TOTAL.PF_CODE = PREFECTURE.PF_CODE
ORDER BY 
    PERCENTAGE DESC
    , CODE
    
    
提出情報
提出日時2022/09/21 19:32:53
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者peter-yusuke
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量105 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
WA
105 MB
データパターン2
AC
105 MB