ソースコード
select * from
(select * from
(select * from PREFECTURE as base
inner join 
(select
    PF_CODE,
    NATION_CODE as '1位 NC',
    AMT as '1位 人数'
    from
    (select
        PF_CODE,
        NATION_CODE,
        AMT,
        row_number() over (partition by PF_CODE order by AMT desc) as rank
        from FOREIGNER
    ) 
    where
        rank = 1
) as first
on base.PF_CODE =first.PF_CODE
) as base_first

inner join 


(select
    PF_CODE,
    NATION_CODE as '2位 NC',
    AMT as '2位 人数'
    from
    (select
        PF_CODE,
        NATION_CODE,
        AMT,
        row_number() over (partition by PF_CODE order by AMT desc) as rank
        from FOREIGNER
    ) 
    where
        rank = 2
) as second
on base_first.PF_CODE = second.PF_CODE
) as base_second
inner join 

(select
    PF_CODE,
    NATION_CODE as '3位 NC',
    AMT as '3位 人数'
    from
    (select
        PF_CODE,
        NATION_CODE,
        AMT,
        row_number() over (partition by PF_CODE order by AMT desc) as rank
        from FOREIGNER
    ) 
    where
        rank = 3
) as third
on base_second.PF_CODE = third.PF_CODE

提出情報
提出日時2023/11/28 17:43:39
コンテスト第1回 SQLコンテスト
問題外国籍分布
受験者yamamtmg
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量87 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
87 MB
データパターン2
WA
84 MB