ソースコード
SELECT a.PF_CODE as CODE
        ,c.PF_NAME as NAME
        ,round(cast(a.o as real) / cast(b.p as real) * 100,1) as PERCENTAGE
  FROM (SELECT  PF_CODE
               ,SUM(AMT) as o
         FROM DRINK_HABITS
         WHERE CATEGORY_CODE = "120"
           AND (GENDER_CODE = "2"
            OR GENDER_CODE = "3")
         GROUP BY PF_CODE
        ) as a
  JOIN (SELECT  PF_CODE
               ,SUM(AMT) as p
         FROM DRINK_HABITS
         WHERE CATEGORY_CODE = "110"
           AND (GENDER_CODE = "2"
            OR GENDER_CODE = "3")
         GROUP BY PF_CODE
        ) as b
  ON a.PF_CODE = b.PF_CODE
  
  LEFT JOIN PREFECTURE as c
   on a.PF_CODE = c.PF_CODE
   
  ORDER BY 
     PERCENTAGE desc
     ,a.PF_CODE desc
提出情報
提出日時2022/09/21 18:26:05
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者inkmori
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量99 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
99 MB
データパターン2
AC
96 MB