ソースコード
SELECT 
  A.PF_CODE  AS CODE,
  PF_NAME   AS NAME,
(
round(100 * cast((SELECT SUM(AMT) FROM DRINK_HABITS AS C WHERE A.PF_CODE = C.PF_CODE 
AND CATEGORY_CODE = '120'
AND GENDER_CODE IN ('2', '3') AND CATEGORY_CODE != '130'
GROUP BY C.PF_CODE) as REAL)
 / cast((SELECT SUM(AMT) FROM DRINK_HABITS AS D WHERE A.PF_CODE = D.PF_CODE
 AND CATEGORY_CODE = '110' AND GENDER_CODE IN ('2', '3') AND CATEGORY_CODE != '130' 
 GROUP BY D.PF_CODE) as REAL),
 
 1)
 ) AS PERCENTAGE
FROM 
  PREFECTURE AS A
WHERE PERCENTAGE IS NOT NULL
  
GROUP BY A.PF_CODE
ORDER BY PERCENTAGE DESC, A.PF_CODE DESC
 
提出情報
提出日時2022/09/22 02:56:08
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者tajima
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
86 MB
データパターン2
AC
85 MB