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