ソースコード
select
sub.PF_CODE as CODE
,PREFECTURE.PF_NAME as NAME
,round(sub.AMT/sub2.AMT * 100,1) as PERCENTAGE
from
(select
PF_CODE
,sum(case GENDER_CODE when '1' then 0 else cast(AMT as REAL) end) as AMT
from DRINK_HABITS
where CATEGORY_CODE = '120'
group by PF_CODE) sub
inner join 
(select
PF_CODE
,sum(case GENDER_CODE when '1' then 0 else cast(AMT as REAL) end) as AMT
from DRINK_HABITS
where CATEGORY_CODE = '110'
group by PF_CODE) sub2
on sub.PF_CODE = sub2.PF_CODE
inner join PREFECTURE
on sub.PF_CODE = PREFECTURE.PF_CODE
order by PERCENTAGE desc,sub.PF_CODE desc;
提出情報
提出日時2022/09/21 18:46:46
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者keita
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量102 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
102 MB
データパターン2
AC
102 MB