ソースコード
SELECT 
TOTAL.PF_CODE AS CODE,
MAX(P.PF_NAME) AS NAME,
ROUND(100*CAST(SUM(EVERYDAY.AMT) AS REAL)/CAST(SUM(TOTAL.AMT) AS REAL),1) AS PERCENTAGE
FROM(
   SELECT PF_CODE,AMT,GENDER_CODE
   FROM DRINK_HABITS
   WHERE CATEGORY_CODE = 110
   AND (GENDER_CODE = 2 OR GENDER_CODE = 3)
)TOTAL
INNER JOIN 
(
    SELECT PF_CODE,AMT,GENDER_CODE
    FROM DRINK_HABITS
    WHERE CATEGORY_CODE = 120
    AND (GENDER_CODE = 2 OR GENDER_CODE = 3)
)EVERYDAY
ON TOTAL.PF_CODE = EVERYDAY.PF_CODE AND TOTAL.GENDER_CODE = EVERYDAY.GENDER_CODE
INNER JOIN PREFECTURE P
ON TOTAL.PF_CODE = P.PF_CODE
GROUP BY TOTAL.PF_CODE
ORDER BY
PERCENTAGE DESC, 
TOTAL.PF_CODE DESC
提出情報
提出日時2023/09/01 16:24:46
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者j-mizuno
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量77 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
77 MB
データパターン2
AC
76 MB