ソースコード
select PREFECTURE.PF_CODE as CODE, PF_NAME as NAME, PERCENTAGE
from PREFECTURE
inner join (select T1.PF_CODE, round(PF_DRINKING * 100.0 / PF_GRAND_TTL, 1) as PERCENTAGE
from (select PF_CODE, sum(AMT) as PF_DRINKING
from DRINK_HABITS
where CATEGORY_CODE = '120'
and GENDER_CODE in (2, 3)
group by PF_CODE) as T1
inner join (select PF_CODE, sum(AMT) as PF_GRAND_TTL
from DRINK_HABITS
where  CATEGORY_CODE = '110'
and GENDER_CODE in (2, 3)
group by PF_CODE) as T2
on T1.PF_CODE = T2.PF_CODE) as T3
on T3.PF_CODE = PREFECTURE.PF_CODE
order by PERCENTAGE desc, PREFECTURE.PF_CODE desc
提出情報
提出日時2024/04/16 11:32:54
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者KAR
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
84 MB