Hypothetical example:
I have an SQL table that contains a billion or so transactions:
| Cost | DateTime | | 1.00 | 2009-01-02 | | 2.00 | 2009-01-03 | | 2.00 | 2009-01-04 | | 3.00 | 2009-01-05 | | 1.00 | 2009-01-06 | ...
What I want is to pair down the data so that I only see the cost transitions:
| Cost | DateTime | | 1.00 | 2009-01-02 | | 2.00 | 2009-01-03 | | 3.00 | 2009-01-05 | | 1.00 | 2009-01-06 | ...
The simplest (and slowest) way to do this is to iterate over the entire table, tracking the changes. Is there a faster/better way to do this in SQL?