ソースコード
with sm as (select 
ITEM_CODE
, SUM(ORDER_QTY) as SQ
, MAX(ORDER_DATE) as MO
from 
ORDERS join ORDERS_DTL on ORDERS.ORDER_NO = ORDERS_DTL.ORDER_NO
where ORDER_DATE between "2023-04-01" and "2023-06-30"
group by ITEM_CODE
)
, smr as (
select ITEM_CODE, rank() over (order by SQ desc, MO desc, ITEM_CODE desc) as rk from sm
)
, nsmr as (
select ITEM_CODE, 0 as rk
from ITEM
where NOT ITEM_CODE IN (
select ITEM_CODE from sm
)
)
, ssmr as (
select * from smr union all
select * from nsmr
)
update item set ITEM_POPULAR_RANK = (select ssmr.rk from ssmr where item.item_code = ssmr.ITEM_CODE)
提出情報
提出日時2024/04/26 17:51:14
コンテスト第8回 SQLコンテスト
問題人気順位
受験者daku10
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
86 MB
データパターン2
AC
85 MB