UPDATE t1
SET t1.DateSeqNo = t2.DateSeqNo
FROM StockHist t1
JOIN (SELECT StockID, QuoteDate,
ROW_NUMBER() OVER (PARTITION BY StockID ORDER BY QuoteDate) AS DateSeqNo
FROM StockHist
WHERE QuoteDate BETWEEN '2009-12-02' AND '2009-12-08') t2
ON t1.StockID = t2.StockID AND t1.QuoteDate = t2.QuoteDate
WHERE t1.StockID = 6842
|