ソースコード
with tt as (
    select
        CLASS_NAME as CLASS,
        PERSON_NAME as PERSON,
        AMT as HOUSEHOLDS,
        CLASS_CODE,
        PERSON_CODE,
        rank() over(
            partition by CLASS_NAME
            order by
                AMT desc
        ) as R
    from
        HOUSEHOLD
    where
        PERSON_CODE != "1"
        and CLASS_CODE != "01"
    order by
        CLASS_CODE,
        PERSON_CODE desc
)
select
    CLASS,
    max(
        case
            when tt.R == 1 then tt.PERSON
            else null
        end
    ) as PERSON,
    max(
        case
            when tt.R == 1 then tt.HOUSEHOLDS
            else null
        end
    ) as HOUSEHOLDS
from
    tt,
    HOUSEHOLD as H
where
    tt.CLASS_CODE == H.CLASS_CODE
    and tt.PERSON_CODE == H.PERSON_CODE
group by
    tt.CLASS_CODE
order by
    tt.CLASS_CODE
提出情報
提出日時2024/02/17 00:54:23
コンテスト第3回 SQLコンテスト
問題最大世帯人員
受験者shogo314
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
84 MB