ソースコード
WITH t2022 AS (
    SELECT
        AREA_CODE AS CODE,
        round(100.0 * FOOD_EXP / CONSUMPTION_EXP, 1) || "%" AS R2022
    FROM
        HOUSEHOLD_SURVEY
    WHERE
        SURVEY_YEAR = 2022
),
c2022 AS (
    SELECT
        CODE,
        R2022,
        dense_rank() over(
            ORDER BY
                R2022 ASC
        ) AS RNK2022
    FROM
        t2022
),
t2017 AS (
    SELECT
        AREA_CODE AS CODE,
        round(100.0 * FOOD_EXP / CONSUMPTION_EXP, 1) || "%" AS R2017
    FROM
        HOUSEHOLD_SURVEY
    WHERE
        SURVEY_YEAR = 2017
),
c2017 AS (
    SELECT
        CODE,
        R2017,
        dense_rank() over(
            ORDER BY
                R2017 ASC
        ) AS RNK2017
    FROM
        t2017
),
t2012 AS (
    SELECT
        AREA_CODE AS CODE,
        round(100.0 * FOOD_EXP / CONSUMPTION_EXP, 1) || "%" AS R2012
    FROM
        HOUSEHOLD_SURVEY
    WHERE
        SURVEY_YEAR = 2012
),
c2012 AS (
    SELECT
        CODE,
        R2012,
        dense_rank() over(
            ORDER BY
                R2012 ASC
        ) AS RNK2012
    FROM
        t2012
)
SELECT
    c2022.CODE AS CODE,
    AREA_NAME AS "NAME",
    RNK2022 AS "2022_RANK",
    R2022 AS "2022_RATIO",
    RNK2017 AS "2017_RANK",
    R2017 AS "2017_RATIO",
    RNK2012 AS "2012_RANK",
    R2012 AS "2012_RATIO"
FROM
    c2022
    INNER JOIN c2017 ON c2022.CODE = c2017.CODE
    INNER JOIN c2012 ON c2022.CODE = c2012.CODE
    INNER JOIN AREA ON c2022.CODE = AREA.AREA_CODE
ORDER BY
    R2022 ASC,
    CODE DESC
提出情報
提出日時2023/12/18 00:02:47
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者asd
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
86 MB
データパターン3
AC
86 MB