ソースコード
select  PF_CODE as CODE, PF_NAME as NAME, round(cast(n_drink as float)  / cast(n_all as float) * 100, 1) as PERCENTAGE from

(select PF_CODE, PF_NAME, sum(AMT) as n_all from DRINK_HABITS
left join PREFECTURE using (PF_CODE)
where GENDER_CODE >= 2 and CATEGORY_CODE = 110
group by PF_NAME
)
left join
(
select PF_CODE, PF_NAME, sum(AMT) as n_drink from DRINK_HABITS
left join PREFECTURE using (PF_CODE)
where GENDER_CODE >= 2 and CATEGORY_CODE = 120
group by PF_NAME
) using (PF_CODE, PF_NAME)
order by PERCENTAGE desc, CODE desc
提出情報
提出日時2022/09/21 21:20:53
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者Tomii9273
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量103 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
100 MB
データパターン2
AC
103 MB