ソースコード
with tmp as (
    select 
        member_code,
        checkup_date,
        row_number() over(partition by member_code order by checkup_date desc) as row_number,
        weight
    from health_checkup
),
tmp1 as (
    select 
        member_code,
        checkup_date,
        row_number,
        weight
    from tmp
    where row_number=1
),
tmp2 as (
    select 
        tmp.member_code as CODE,
        tmp.checkup_date as CK_DATE_old,
        tmp.weight as WE_old,
        tmp1.checkup_date as CK_DATE,
        tmp1.weight as WE_new    
    from tmp
    inner join tmp1
    on tmp1.member_code=tmp.member_code
    where tmp.row_number=2
)
select 
    CODE,
    CK_DATE,
    last_name || first_name as NAME,
    (we_new*10-we_old*10)/10 as CHG_WT
from tmp2
inner join member_mst
on tmp2.code=member_mst.member_code
where abs(we_new*10-we_old*10)>=50
order by CHG_WT desc,code desc;
提出情報
提出日時2024/12/14 23:09:08
コンテスト第13回 SQLコンテスト
問題体重差分
受験者kate
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
85 MB