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