ソースコード
WITH table2022 AS
(
SELECT
    HS.AREA_CODE CODE,
    A.AREA_NAME NAME,    
    ROUND(((1.0*FOOD_EXP/CONSUMPTION_EXP)*100),1)||"%" AS "2022_RATIO",
    DENSE_RANK() OVER(ORDER BY ROUND(((1.0*FOOD_EXP/CONSUMPTION_EXP)*100),1) ASC) "2022_RANK"
FROM
    HOUSEHOLD_SURVEY HS
    INNER JOIN AREA A ON HS.AREA_CODE = A.AREA_CODE
WHERE 1=1
    AND HS.SURVEY_YEAR = 2022
ORDER BY "2022_RATIO" ASC,
CODE DESC
),
table2017 AS (
SELECT
    HS.AREA_CODE CODE,
    ROUND(((1.0*FOOD_EXP/CONSUMPTION_EXP)*100),1)||"%" AS "2017_RATIO",
    DENSE_RANK() OVER(ORDER BY ROUND(((1.0*FOOD_EXP/CONSUMPTION_EXP)*100),1) ASC) "2017_RANK"
FROM
    HOUSEHOLD_SURVEY HS
    INNER JOIN AREA A ON HS.AREA_CODE = A.AREA_CODE
WHERE 1=1
    AND HS.SURVEY_YEAR = 2017
),
table2012 AS (
SELECT
    HS.AREA_CODE CODE,
    A.AREA_NAME NAME,    
    ROUND(((1.0*FOOD_EXP/CONSUMPTION_EXP)*100),1)||"%" AS "2012_RATIO",
    DENSE_RANK() OVER(ORDER BY ROUND(((1.0*FOOD_EXP/CONSUMPTION_EXP)*100),1) ASC) "2012_RANK"
FROM
    HOUSEHOLD_SURVEY HS
    INNER JOIN AREA A ON HS.AREA_CODE = A.AREA_CODE
WHERE 1=1
    AND HS.SURVEY_YEAR = 2012
)
SELECT * FROM table2022 t22
INNER JOIN table2017 t17 ON t22.CODE = t17.CODE
INNER JOIN table2012 t12 ON t22.CODE = t12.CODE
ORDER BY "2022_RANK" ASC, CODE DESC
提出情報
提出日時2023/12/17 21:20:10
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者fractal1024
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
85 MB
データパターン3
AC
85 MB