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