ソースコード
with
man_total as (select * from DRINK_HABITS where CATEGORY_CODE = 110 and GENDER_CODE = 2),
woman_total as (select * from DRINK_HABITS where CATEGORY_CODE = 110 and GENDER_CODE = 3),
man_drink as (select * from DRINK_HABITS where CATEGORY_CODE = 120 and GENDER_CODE = 2),
woman_drink as (select * from DRINK_HABITS where CATEGORY_CODE = 120 and GENDER_CODE = 3)
select
PREFECTURE.PF_CODE as CODE,
PREFECTURE.PF_NAME as NAME,
round(cast(man_drink.AMT + woman_drink.AMT as REAL) / cast(man_total.AMT + woman_total.AMT as REAL) * 100, 1) as PERCENTAGE
from
PREFECTURE
join man_total on man_total.PF_CODE = PREFECTURE.PF_CODE
join woman_total on woman_total.PF_CODE = PREFECTURE.PF_CODE
join man_drink on man_drink.PF_CODE = PREFECTURE.PF_CODE
join woman_drink on woman_drink.PF_CODE = PREFECTURE.PF_CODE
order by PERCENTAGE desc, CODE desc
提出情報
提出日時2022/09/21 21:40:15
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者nenecchi
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量101 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
101 MB
データパターン2
AC
98 MB