ソースコード
update ITEM 
set ITEM_POPULAR_RANK = B.ida
from
(
select row_number() over (order by cnt desc, max(ORDER_DATE) desc, it.ITEM_CODE desc) as ida
, it.ITEM_CODE , cnt, max(ORDER_DATE) as dt from ITEM as it
   left join ORDERS_DTL as od on od.ITEM_CODE  = it.ITEM_CODE 
   left join ORDERS as o on o.ORDER_NO = od.ORDER_NO
   inner join (
   select it.ITEM_CODE , ifnull(sum(ORDER_QTY),0) as cnt from ITEM as it
   left join ORDERS_DTL as od on od.ITEM_CODE  = it.ITEM_CODE 
   left join ORDERS as o on o.ORDER_NO = od.ORDER_NO

   group by it.ITEM_CODE
   order by cnt desc
) as temp on temp.ITEM_CODE = it.ITEM_CODE

   group by it.ITEM_CODE
   order by cnt desc,dt desc, it.ITEM_CODE desc) as B
   where ITEM.ITEM_CODE = B.ITEM_CODE
提出情報
提出日時2023/08/21 11:39:52
コンテスト第8回 SQLコンテスト
問題人気順位
受験者ryo_tokyo
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量104 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
104 MB
データパターン2
WA
103 MB