ソースコード
SELECT BASE.AREA_CODE,
       M1.AREA_NAME,
       BASE.RANK AS "2022_RANK",
       BASE.RATIO || '%' AS "2022_RATIO",
       T1.RANK AS "2017_RANK",
       T1.RATIO || '%' AS "2017_RATIO",
       T2.RANK AS "2012_RANK",
       T2.RATIO || '%' AS "2012_RATIO"
  FROM (SELECT AREA_CODE,
               RATIO,
               dense_rank() over (order by RATIO) AS RANK
          FROM (SELECT AREA_CODE,
                       ROUND(CAST(FOOD_EXP AS REAL) / CONSUMPTION_EXP * 100,1) AS RATIO
                  FROM HOUSEHOLD_SURVEY
                 WHERE SURVEY_YEAR = 2022
                ) 
       ) BASE INNER JOIN AREA M1
                 ON BASE.AREA_CODE = M1.AREA_CODE
              INNER JOIN (SELECT AREA_CODE,
                                 RATIO,
                                 dense_rank() over (order by RATIO) AS RANK
                            FROM (SELECT AREA_CODE,
                                         ROUND(CAST(FOOD_EXP AS REAL) / CONSUMPTION_EXP * 100,1) AS RATIO
                                    FROM HOUSEHOLD_SURVEY
                                   WHERE SURVEY_YEAR = 2017
                                  ) 
                          ) T1
                 ON BASE.AREA_CODE = T1.AREA_CODE
              INNER JOIN (SELECT AREA_CODE,
                                 RATIO,
                                 dense_rank() over (order by RATIO) AS RANK
                            FROM (SELECT AREA_CODE,
                                         ROUND(CAST(FOOD_EXP AS REAL) / CONSUMPTION_EXP * 100,1) AS RATIO
                                    FROM HOUSEHOLD_SURVEY
                                   WHERE SURVEY_YEAR = 2012
                                  ) 
                          ) T2
                 ON BASE.AREA_CODE = T2.AREA_CODE
  ORDER BY BASE.RANK ASC,BASE.AREA_CODE DESC
提出情報
提出日時2023/12/16 21:32:46
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者yng
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
84 MB
データパターン2
WA
84 MB
データパターン3
WA
85 MB