ソースコード
SELECT 
PF_CODE AS CODE
,PF_NAME AS NAME
,ROUND(CAST(DRINKPEOPLE as float )/ALLPEOPLE*100,1) AS PERCENTAGE
FROM(
SELECT
A.PF_CODE
,A.ALLPEOPLE
,EVERYDAY.DRINKPEOPLE
,C.PF_NAME
FROM
(SELECT PF_CODE,SUM(AMT) AS ALLPEOPLE
FROM DRINK_HABITS
WHERE GENDER_CODE IN ('2','3')
AND CATEGORY_CODE = '110'
GROUP BY PF_CODE
) A
LEFT JOIN 
(SELECT PF_CODE,SUM(AMT) AS DRINKPEOPLE
FROM DRINK_HABITS
WHERE GENDER_CODE IN ('2','3')
AND CATEGORY_CODE = '120'
GROUP BY PF_CODE) EVERYDAY
ON A.PF_CODE = EVERYDAY.PF_CODE
LEFT JOIN 
PREFECTURE C
ON A.PF_CODE = C.PF_CODE
)
ORDER BY PERCENTAGE DESC ,PF_CODE DESC
提出情報
提出日時2022/09/22 02:00:16
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者Se_kire_i
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
76 MB