ソースコード
SELECT 
    A.AREA_CODE AS CODE,
    B.AREA_NAME AS NAME,
    "2022_RANK",
    "2022_RATIO" || '%' AS "2022_RATIO",
    "2017_RANK",
    "2017_RATIO" || '%' AS "2017_RATIO",
    "2012_RANK",
    "2012_RATIO" || '%' AS "2012_RATIO"
FROM (
    SELECT
        A22.AREA_CODE,
        "2022_RANK",
        "2022_RATIO",
        "2017_RANK",
        "2017_RATIO",
        "2012_RANK",
        "2012_RATIO"
    FROM 
    (
        SELECT 
            AREA_CODE,
            ROUND(100.0 * FOOD_EXP / CONSUMPTION_EXP, 1) AS "2022_RATIO",
            DENSE_RANK() OVER (ORDER BY ROUND(100.0 * FOOD_EXP / CONSUMPTION_EXP, 1)) AS "2022_RANK"
        FROM HOUSEHOLD_SURVEY
        WHERE SURVEY_YEAR = '2022'
    ) AS A22
    NATURAL JOIN
    (
        SELECT 
            AREA_CODE,
            ROUND(100.0 * FOOD_EXP / CONSUMPTION_EXP, 1) AS "2017_RATIO",
            DENSE_RANK() OVER (ORDER BY ROUND(100.0 * FOOD_EXP / CONSUMPTION_EXP, 1)) AS "2017_RANK"
        FROM HOUSEHOLD_SURVEY
        WHERE SURVEY_YEAR = '2017'
    ) AS A17
    NATURAL JOIN
    (
        SELECT 
            AREA_CODE,
            ROUND(100.0 * FOOD_EXP / CONSUMPTION_EXP, 1) AS "2012_RATIO",
            DENSE_RANK() OVER (ORDER BY ROUND(100.0 * FOOD_EXP / CONSUMPTION_EXP, 1)) AS "2012_RANK"
        FROM HOUSEHOLD_SURVEY
        WHERE SURVEY_YEAR = '2012'
    ) AS A12
        
        
) AS A
INNER JOIN AREA AS B
ON A.AREA_CODE = B.AREA_CODE
ORDER BY "2022_RANK", CODE DESC
提出情報
提出日時2023/12/15 16:56:26
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者nadia
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量98 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
98 MB
データパターン3
AC
98 MB