ソースコード
SELECT 
 P.PF_CODE AS CODE,
 P.PF_NAME AS NAME, 
 ROUND (D1.SUM / D2.SUM * 100, 1) AS PERCENTAGE
FROM
 PREFECTURE AS P
JOIN (
 SELECT
  PF_CODE, TOTAL (AMT) AS SUM
  FROM DRINK_HABITS
  WHERE CATEGORY_CODE = '120'
  AND GENDER_CODE <> '1'
  GROUP BY PF_CODE
 ) AS D1 
ON
 D1.PF_CODE = P.PF_CODE
JOIN (
 SELECT 
  PF_CODE, TOTAL (AMT) AS SUM
  FROM DRINK_HABITS
  WHERE CATEGORY_CODE = '110'
  AND GENDER_CODE <> '1'
  GROUP BY PF_CODE
 ) AS D2
ON
 D2.PF_CODE = P.PF_CODE
ORDER BY
 PERCENTAGE DESC,
 P.PF_CODE DESC;
提出情報
提出日時2022/09/22 11:02:21
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者nagata
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量105 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
95 MB
データパターン2
AC
105 MB