ソースコード
with TMP as (
    select
        ITEM_CODE
        , row_number() over (order by SUM_ORDER_QTY desc, LATEST_ORDER_DATE desc, ITEM_CODE desc) as RANKING
    from
        (
        select
            sum(D.ORDER_QTY) as SUM_ORDER_QTY
            , max(O.ORDER_DATE) as LATEST_ORDER_DATE
            , D.ITEM_CODE as ITEM_CODE
        from
            ORDERS as O
        left join
            ORDERS_DTL as D on O.ORDER_NO=D.ORDER_NO
        where
            O.ORDER_DATE between '2023-04-01' and '2023-06-30'
        group by
            D.ITEM_CODE
        )
)
update 
    ITEM as I
set
    ITEM_POPULAR_RANK=coalesce((select RANKING from TMP as T where I.ITEM_CODE=T.ITEM_CODE), 0)
;
提出情報
提出日時2024/07/07 00:47:31
コンテスト第8回 SQLコンテスト
問題人気順位
受験者poapoa1010
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
85 MB