ソースコード
WITH t1 AS (
    SELECT
        PF_CODE, SUM(AMT) AS total1
    FROM
        DRINK_HABITS
    INNER JOIN
        PREFECTURE USING (PF_CODE)
    WHERE
        CATEGORY_CODE = 110
        AND GENDER_CODE IN (2, 3)
    GROUP BY
        PF_CODE
),
t2 AS (
    SELECT
        PF_CODE, SUM(AMT) AS total2
    FROM
        DRINK_HABITS
    INNER JOIN
        PREFECTURE USING (PF_CODE)
    WHERE
        CATEGORY_CODE = 120
        AND GENDER_CODE IN (2, 3)
    GROUP BY
        PF_CODE
)
SELECT
    PF_CODE AS CODE,
    PF_NAME AS NAME,
    ROUND(CAST(total2 AS real) / CAST(total1 AS real) * 100, 2) AS PERCENTAGE
FROM
    t1
INNER JOIN
    t2 USING (PF_CODE)
INNER JOIN
    PREFECTURE USING (PF_CODE)
ORDER BY
    CAST(total2 AS real) / CAST(total1 AS real) * 100 DESC,
    PF_CODE DESC
提出情報
提出日時2022/09/22 09:46:32
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者ikd
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量99 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
99 MB
データパターン2
WA
96 MB