Let us consider the example of a stock system. Suppose that in each
transaction, cumulative totals of sales are kept. Now to find the
cumulative sales at any time a composite index of stockcode and transaction
timestamp could be stored. To access the index a composite key of stock
code and timestamp (for the time at which we want to know the stock level)
could be used to access the index. In all likelyhood there was no
transaction at exactly that time. So we need to back up the index to the
previous record. If there is no previous record, or the previous record has
a different stock code then we know that the cumulative sales at that time
is zero.
How do I do this with MS Sql server?
Looking forward to your replies.
Tony