ソースコード
SELECT
    SUB1.PF_CODE AS '都道府県コード', SUB1.PF_NAME AS '都道府県名',
    SUB2.'2015' AS '総人口2015年', SUB2.'2020' AS '総人口2020年',
    ROUND(CAST(SUB1.P_INTEREST AS REAL) / CAST(SUB2.'2015' AS REAL) * 100, 0) + 100 AS '人口増加率'
FROM

(SELECT
  PREF.PF_CODE,
  PREF.PF_NAME,
  P_DIFF.P_INTEREST
FROM PREFECTURE AS PREF
LEFT JOIN (SELECT
  SURVEY_YEAR,
  PF_CODE,
  SUM(CASE SURVEY_YEAR
    WHEN 2015 THEN -1 * TOTAL_AMT
    ELSE TOTAL_AMT
  END) AS P_INTEREST

  FROM POPU_TRANSITION
  WHERE SURVEY_YEAR IN (2015, 2020)
  GROUP BY PF_CODE
  HAVING P_INTEREST >=0
  ORDER BY P_INTEREST DESC
) AS P_DIFF
ON PREF.PF_CODE = P_DIFF.PF_CODE
WHERE P_INTEREST IS NOT NULL) AS SUB1

LEFT JOIN

(SELECT
    POP_A.PF_CODE, POP_A.TOTAL_AMT AS '2015', POP_C.'2020'
    FROM POPU_TRANSITION AS POP_A

LEFT JOIN (
    SELECT
        POP_B.PF_CODE, POP_B.TOTAL_AMT AS '2020'
        FROM POPU_TRANSITION AS POP_B
        WHERE SURVEY_YEAR = 2020
) AS POP_C

ON POP_A.PF_CODE = POP_C.PF_CODE
WHERE POP_A.SURVEY_YEAR = 2015
) AS SUB2

ON SUB1.PF_CODE = SUB2.PF_CODE
ORDER BY '都道府県コード' ASC

提出情報
提出日時2022/07/17 10:11:03
コンテスト練習用コンテスト
問題人口増加率分析
受験者YohKmb
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量77 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
77 MB
データパターン2
WA
76 MB