ソースコード
WITH SUBSUM AS (
    SELECT
        PF_CODE
      , SUM(CASE WHEN CATEGORY_CODE = '110' THEN AMT ELSE 0 END) AS SUM_ALL
      , SUM(CASE WHEN CATEGORY_CODE = '120' THEN AMT ELSE 0 END) AS SUM_EVERY
    FROM
        DRINK_HABITS
    WHERE
        GENDER_CODE IN ('2', '3')
    GROUP BY
        PF_CODE
)
SELECT
    T1.PF_CODE AS "CODE"
  , M1.PF_NAME AS "NAME"
  , ROUND(CAST(T1.SUM_EVERY AS REAL) / CAST(T1.SUM_ALL AS REAL) * 100, 1) AS "PERCENTAGE"
FROM
    SUBSUM T1
    LEFT OUTER JOIN PREFECTURE M1
        ON T1.PF_CODE = M1.PF_CODE
ORDER BY
    PERCENTAGE DESC
  , CODE       DESC
;
提出情報
提出日時2022/09/22 08:00:16
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者kntky98
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量88 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
88 MB
データパターン2
AC
85 MB