I have a database that is filled with time series data points on different items. I would like to calculate the difference between values by item for the time series and then store it in a difference column. My table is as follows:
id | Ticker | Date | SO | difference
1 | QQQQ | 2011-01-03 | 200000 | 0
2 | QQQQ | 2011-01-04 | 200100 | 100
3 | QQQQ | 2011-01-05 | 201000 | 900
4 | PWC | 2011-01-03 | 180000 | 0
5 | PWC | 2011-01-04 | 180500 | 500
6 | PWC | 2011-01-05 | 181000 | 500
I would like to calculate the difference column when ever new points are added. How would you recommend to do this?