ソースコード
with drink_everyday as(
    select 
        PF_CODE, 
        sum(AMT) as amt
    from DRINK_HABITS
    where CATEGORY_CODE = '120' and GENDER_CODE in (2, 3)
    group by PF_CODE
), 
    drink_all as(
    select 
        PF_CODE, 
        sum(AMT) as amt
    from DRINK_HABITS
    where CATEGORY_CODE = '110' and GENDER_CODE in (2, 3)
    group by PF_CODE
) 
select 
    p.PF_CODE as CODE, 
    p.PF_NAME as NAME, 
    round(100 * cast(de.amt as real) / cast(da.amt as real) , 1) as PERCENTAGE
from drink_everyday as de
    inner join drink_all as da on de.PF_CODE = da.PF_CODE
    inner join PREFECTURE as p on de.PF_CODE = p.PF_CODE
order by PERCENTAGE desc, code desc
;
提出情報
提出日時2023/10/31 13:57:30
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者fgdthfjgh
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量78 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
76 MB
データパターン2
AC
78 MB