ソースコード
select 
      a1.pf_code as "CODE" 
     ,a1.PF_NAME as "NAME"
     ,round(cast(a1.amt_sum as REAL)/cast(a2.amt_sum as REAL) * 100,1) as "PERCENTAGE"
    from
      (select a.pf_code,b.PF_NAME,sum(a.AMT) as amt_sum
      from   DRINK_HABITS a
            ,PREFECTURE   b
      where
          a.pf_code = b.pf_code
      and a.GENDER_CODE in ('2','3')
      and a.CATEGORY_CODE in ('120')
      group by b.PF_NAME) a1
     ,(select a.pf_code,b.PF_NAME,sum(a.AMT) as amt_sum
      from   DRINK_HABITS a
            ,PREFECTURE   b
      where
          a.pf_code = b.pf_code
      and a.GENDER_CODE in ('2','3')
      and a.CATEGORY_CODE in ('110')
      group by b.PF_NAME) a2
    where
      a1.PF_NAME = a2.PF_NAME
    order by round(cast(a1.amt_sum as REAL)/cast(a2.amt_sum as REAL) * 100,1) desc
            ,a1.pf_code desc
提出情報
提出日時2022/09/21 23:41:14
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者O.I.
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量106 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
106 MB
データパターン2
AC
94 MB