コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
WITH RANKING2022 AS (
SELECT
a.AREA_CODE AS CODE
, AREA_NAME AS NAME
, ROUND(CAST(FOOD_EXP AS FLOAT) / CONSUMPTION_EXP * 100, 1) || '%' AS RATIO
, DENSE_RANK() OVER (ORDER BY ROUND(CAST(FOOD_EXP AS FLOAT) / CONSUMPTION_EXP * 100, 1)) AS RANK
FROM
HOUSEHOLD_SURVEY a
INNER JOIN AREA b ON
a.AREA_CODE = b.AREA_CODE
WHERE
SURVEY_YEAR = 2022
),
RANKING2017 AS (
SELECT
a.AREA_CODE AS CODE
, AREA_NAME AS NAME
, ROUND(CAST(FOOD_EXP AS FLOAT) / CONSUMPTION_EXP * 100, 1) || '%' AS RATIO
, DENSE_RANK() OVER (ORDER BY ROUND(CAST(FOOD_EXP AS FLOAT) / CONSUMPTION_EXP * 100, 1)) AS RANK
FROM
HOUSEHOLD_SURVEY a
INNER JOIN AREA b ON
a.AREA_CODE = b.AREA_CODE
WHERE
SURVEY_YEAR = 2017
),
RANKING2012 AS (
SELECT
a.AREA_CODE AS CODE
, AREA_NAME AS NAME
, ROUND(CAST(FOOD_EXP AS FLOAT) / CONSUMPTION_EXP * 100, 1) || '%' AS RATIO
, DENSE_RANK() OVER (ORDER BY ROUND(CAST(FOOD_EXP AS FLOAT) / CONSUMPTION_EXP * 100, 1)) AS RANK
FROM
HOUSEHOLD_SURVEY a
INNER JOIN AREA b ON
a.AREA_CODE = b.AREA_CODE
WHERE
SURVEY_YEAR = 2012
)
SELECT
a.CODE
, a.NAME
, a.RANK AS '2022_RANK'
, a.RATIO AS '2022_RATIO'
, b.RANK AS '2017_RANK'
, b.RATIO AS '2017_RATIO'
, c.RANK AS '2012_RANK'
, c.RATIO AS '2012_RATIO'
FROM
RANKING2022 a
LEFT JOIN RANKING2017 b ON
a.CODE = b.CODE
LEFT JOIN RANKING2012 c ON
a.CODE = c.CODE
ORDER BY
a.RANK
, a.CODE DESC
;
提出情報
提出日時 | 2024/02/09 14:04:50 |
コンテスト | 第10回 SQLコンテスト |
問題 | 食料費の割合 |
受験者 | SQL2022 |
状態 (詳細) | AC (Accepted: 正答) |
メモリ使用量 | 86 MB |
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
85 MB
データパターン3
AC
86 MB