ソースコード
SELECT DH_110.PF_CODE AS CODE, P.PF_NAME AS NAME, ROUND(CAST(DH_120.TOTAL_AMT AS REAL) / CAST(DH_110.TOTAL_AMT AS REAL) * 100, 1) AS PERCENTAGE
FROM (
  SELECT PF_CODE, SUM(AMT) AS TOTAL_AMT
  FROM DRINK_HABITS
  WHERE CATEGORY_CODE = '110' AND GENDER_CODE IN ('2', '3')
  GROUP BY PF_CODE
) AS DH_110
JOIN PREFECTURE AS P ON DH_110.PF_CODE = P.PF_CODE
JOIN (
  SELECT PF_CODE, SUM(AMT) AS TOTAL_AMT
  FROM DRINK_HABITS
  WHERE CATEGORY_CODE = '120' AND GENDER_CODE IN ('2', '3')
  GROUP BY PF_CODE
) AS DH_120 ON DH_110.PF_CODE = DH_120.PF_CODE
ORDER BY PERCENTAGE DESC, CODE DESC;
提出情報
提出日時2023/12/04 12:59:53
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者tkiry
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
86 MB