ソースコード
with target as (
    select
        h.AREA_CODE as 'CODE'
        , AREA_NAME as 'NAME'
        , SURVEY_YEAR
        , round((cast(FOOD_EXP as REAL)/ cast(CONSUMPTION_EXP as REAL) * 100.0), 1) as 'RATIO'
    from
        HOUSEHOLD_SURVEY h
        inner join AREA a on h.AREA_CODE = a.AREA_CODE
    where
        SURVEY_YEAR in ('2022', '2017', '2012')
    group by
        SURVEY_YEAR
        , h.AREA_CODE
), 2022_rank as (
    select
        CODE
        , NAME
        , dense_rank() over (order by RATIO asc) as '2022_RANK'
        , RATIO || '%' as '2022_RATIO'
    from
        target
    where
        SURVEY_YEAR = '2022'
), 2017_rank as (
    select
        CODE
        , NAME
        , dense_rank() over (order by RATIO asc) as '2017_RANK'
        , RATIO || '%' as '2017_RATIO'
    from
        target
    where
        SURVEY_YEAR = '2017'
), 2012_rank as (
    select
        CODE
        , NAME
        , dense_rank() over (order by RATIO asc) as '2012_RANK'
        , RATIO || '%' as '2012_RATIO'
    from
        target
    where
        SURVEY_YEAR = '2012'
)
select
    *
from
    2022_rank
    inner join 2017_rank on 2022_rank.CODE = 2017_rank.CODE
    inner join 2012_rank on 2022_rank.CODE = 2012_rank.CODE
;
提出情報
提出日時2023/12/18 11:55:04
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者toridashisoba
状態 (詳細)RE
(Runtime Error: 実行時エラー)
メモリ使用量102 MB
メッセージ
SQLITE_ERROR: unrecognized token: "2022_rank"
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
RE
99 MB
データパターン2
RE
102 MB
データパターン3
RE
87 MB