ソースコード
select d.pf_code as 'CODE'
       , p.pf_name as 'NAME'
       , round(cast(d2.sum as real) / cast(d.sum as real) * 100 , 1) as 'PERCENTAGE'
from (select PF_CODE
             , sum(amt) as sum
       from  drink_habits 
       where 1 = 1
       and (gender_code = '2' 
       or gender_code = '3')
       and category_code = '110'
       group by PF_CODE) as d
inner join (select PF_CODE
             , sum(amt) as sum
       from  drink_habits 
       where 1 = 1
       and (gender_code = '2' 
       or gender_code = '3')
       and category_code = '120'
       group by PF_CODE) as d2
       on d.pf_code = d2.pf_code
inner join prefecture as p
on d.pf_code = p.pf_code
where 1 = 1 
group by d.pf_code
       , p.pf_name
order by PERCENTAGE desc, CODE desc;
提出情報
提出日時2022/09/21 18:19:14
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者roundoneknockout
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量97 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
97 MB
データパターン2
AC
95 MB