Posted by Jens on 11/03/05 14:54
UPDATE #Tempone SET
differenceValue =
((SELECT TOP 1 latestclosingprice
FROM #Tempone T2
WHERE T1.companyid = T2.companyid
AND T2.dailydate > T1.dailydate
ORDER BY dailydate ASC )
/ (CASE SomeValue WHEN 0 THEN NULL ELSE SomeValue END)-1)*100
FROM #Tempone T1
That assumes that only one entry per date exists, because otherwise
there would be a unpredicted way to sort the results.
[Back to original message]
|