ソースコード
    with result_2022 AS
    (
        select 
             area_code
            ,ROUND(100.0 * food_exp / consumption_exp, 1) r
            ,DENSE_RANK() over (order by ROUND(100.0 * food_exp / consumption_exp, 1 ) ) ra
        from 
            household_survey
        where survey_year = 2022
        group by area_code
    ), 
    result_2017 AS
    (
        select 
             area_code
            ,ROUND(100.0 * food_exp / consumption_exp, 1) r 
            ,DENSE_RANK() over (order by ROUND(100.0 * food_exp / consumption_exp, 1 ) ) ra 
        from
            household_survey
        where survey_year = 2017
        group by area_code
    ), 
    result_2012 AS
    (
        select 
             area_code
            ,ROUND(100.0 * food_exp / consumption_exp, 1) r 
            ,DENSE_RANK() over (order by ROUND(100.0 * food_exp / consumption_exp, 1 ) ) ra
        from
            household_survey
        where survey_year = 2012
        group by area_code
    )
    select 
         result_2022.area_code code
        ,area.area_name NAME
        ,result_2022.ra "2022_RANK"
        ,result_2022.r || '%'  "2022_RATIO"
        ,result_2017.ra "2017_RANK"
        ,result_2017.r || '%'  "2017_RATIO"  
        ,result_2012.ra "2012_RANK"
        ,result_2012.r || '%'  "2012_RATIO"
    from
        result_2022
    inner join
        result_2017
    on
        result_2022.area_code = result_2017.area_code
    inner join  
        result_2012
    on
        result_2022.area_code = result_2012.area_code
    inner join
        area
    on
        result_2022.area_code = area.area_code
    order by "2022_RATIO", code desc
    ;
提出情報
提出日時2023/12/15 15:46:39
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者Kojiron
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量92 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
85 MB
データパターン2
WA
92 MB
データパターン3
WA
92 MB