ソースコード
select re.code AS 'CODE',re.name AS 'NAME',ROUND(re.sum*100.0/res.sum,1) as 'PERCENTAGE'
from 
(
    select pr.PF_CODE as 'code',pr.PF_NAME as 'name',SUM(dr.AMT) as 'sum'
    from DRINK_HABITS dr,PREFECTURE pr 
    where dr.CATEGORY_CODE= '120'
    and (dr.GENDER_CODE = '2' or dr.GENDER_CODE= '3')
    and dr.PF_CODE= pr.PF_CODE
    group by pr.PF_CODE,pr.PF_NAME
) re,
(
    select pr.PF_CODE as 'code',pr.PF_NAME as 'name',SUM(dr.AMT) as 'sum'
    from DRINK_HABITS dr,PREFECTURE pr 
    where dr.CATEGORY_CODE= '110'
    and (dr.GENDER_CODE = '2' or dr.GENDER_CODE= '3')
    and dr.PF_CODE= pr.PF_CODE
    group by pr.PF_CODE,pr.PF_NAME
) res
where re.code = res.code
and re.name= res.name
order by ROUND(re.sum*100.0/res.sum,1) desc, code desc
提出情報
提出日時2022/09/22 00:34:14
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者goudezhao
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量96 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
94 MB
データパターン2
AC
96 MB