ソースコード
select
    P.PF_CODE,
    R1.NATION_CODE,
    R2.NATION_CODE,
    R3.NATION_CODE
From
    PREFECTURE P
LEFT JOIN
    (
        select
            *
        from
        (
            select
                R.*,
                ROW_NUMBER() OVER(PARTITION BY R.PF_CODE ORDER BY R.PF_CODE ASC) Num
            from 
            (
                select
                    F.PF_CODE,
                    F.NATION_CODE,
                    F.AMT,
                    N.NATION_NAME
                From
                    FOREIGNER F
                LEFT JOIN NATIONALITY N ON N.NATION_CODE = F.NATION_CODE
                order by 
                    F.PF_CODE,
                    F.AMT desc
            ) as R
        )
        where Num = 1
    ) R1 ON R1.PF_CODE = P.PF_CODE
LEFT JOIN
    (
        select
            *
        from
        (
            select
                R.*,
                ROW_NUMBER() OVER(PARTITION BY R.PF_CODE ORDER BY R.PF_CODE ASC) Num
            from 
            (
                select
                    F.PF_CODE,
                    F.NATION_CODE,
                    F.AMT,
                    N.NATION_NAME
                From
                    FOREIGNER F
                LEFT JOIN NATIONALITY N ON N.NATION_CODE = F.NATION_CODE
                order by 
                    F.PF_CODE,
                    F.AMT desc
            ) as R
        )
        where Num = 2
    ) R2 ON R2.PF_CODE = P.PF_CODE
LEFT JOIN
    (
        select
            *
        from
        (
            select
                R.*,
                ROW_NUMBER() OVER(PARTITION BY R.PF_CODE ORDER BY R.PF_CODE ASC) Num
            from 
            (
                select
                    F.PF_CODE,
                    F.NATION_CODE,
                    F.AMT,
                    N.NATION_NAME
                From
                    FOREIGNER F
                LEFT JOIN NATIONALITY N ON N.NATION_CODE = F.NATION_CODE
                order by 
                    F.PF_CODE,
                    F.AMT desc
            ) as R
        )
        where Num = 3
    ) R3 ON R3.PF_CODE = P.PF_CODE
提出情報
提出日時2022/07/20 18:49:21
コンテスト第1回 SQLコンテスト
問題外国籍分布
受験者naichilab
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量105 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
105 MB
データパターン2
WA
100 MB