ソースコード
SELECT
        tg.PF_CODE as CODE
        ,pr.PF_NAME as 'NAME'
        ,ROUND((1.0*tg.sum_tgt/tmp.sum_amt)*100,1) as 'PERCENTAGE'
FROM (
    SELECT
        PF_CODE
        ,sum(AMT) as sum_tgt
    FROM
        DRINK_HABITS
    WHERE (GENDER_CODE != '1') and (CATEGORY_CODE = '120')
    GROUP BY 
        PF_CODE
    ) as tg
INNER JOIN(
    SELECT
        PF_CODE
        ,sum(AMT) as sum_amt
    FROM
        DRINK_HABITS
    WHERE (GENDER_CODE != '1') and (CATEGORY_CODE = '110')
    GROUP BY 
        PF_CODE
)as tmp ON tg.PF_CODE = tmp.PF_CODE
INNER JOIN PREFECTURE as pr ON tg.PF_CODE = pr.PF_CODE
ORDER BY 
    PERCENTAGE DESC
    ,CODE DESC
;

提出情報
提出日時2022/09/24 17:55:50
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者yy16ki
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量80 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
77 MB
データパターン2
AC
80 MB