ソースコード
WITH SUB1 AS
(SELECT OD.ITEM_CODE AS ITEM_CODE,
SUM(ORDER_QTY) AS ORDER_AMT,
MAX(ORDER_DATE) AS LAST_ORDER_DATE
FROM ORDERS_DTL OD INNER JOIN ORDERS O
ON OD.ORDER_NO = O.ORDER_NO
AND ORDER_DATE BETWEEN '2023-04-01' AND '2023-06-30'
GROUP BY ITEM_CODE),
SUB2 AS
(SELECT ITEM_CODE FROM ITEM)
UPDATE ITEM
SET ITEM_POPULAR_RANK = CASE
WHEN SUB3.ORDER_AMT IS NULL THEN RANKING
ELSE 0 END
FROM(SELECT SUB2.ITEM_CODE AS ITEM_CODE, ORDER_AMT,
RANK() OVER (ORDER BY ORDER_AMT DESC, LAST_ORDER_DATE DESC, SUB2.ITEM_CODE DESC) AS RANKING
FROM SUB2 LEFT JOIN SUB1
ON SUB2.ITEM_CODE = SUB1.ITEM_CODE) AS SUB3
WHERE ITEM.ITEM_CODE = SUB3.ITEM_CODE
提出情報
提出日時2024/06/17 21:28:00
コンテスト第8回 SQLコンテスト
問題人気順位
受験者yanagiguchi
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量84 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
84 MB
データパターン2
WA
84 MB