I have a table like
Id_indicator Value trend Date_data
1 0 0 2011-08-18 09:16:15
1 2 1 2011-08-18 10:16:15
1 1 -1 2011-08-18 11:16:15
1 2 1 2011-08-18 12:16:15
2 21 0 2011-08-18 13:16:15
2 21 0 2011-08-18 14:16:15
2 21 0 2011-08-18 15:16:15
3 3 0 2011-08-18 16:16:15
3 4 1 2011-08-18 17:16:15
3 4 0 2011-08-18 18:16:15
4 4 0 2011-08-18 19:16:15
I need to find out what is the difference between previous values based on id_indicator and add a column in the right and input that value. example as
Id_indicator Value trend Date_data Difference
1 0 0 2011-08-18 09:16:15 0
1 2 1 2011-08-18 10:16:15 2
1 1 -1 2011-08-18 11:16:15 -1
1 2 1 2011-08-18 12:16:15 1
2 21 0 2011-08-18 13:16:15 0
2 21 0 2011-08-18 14:16:15 0
2 21 0 2011-08-18 15:16:15 0
3 3 0 2011-08-18 16:16:15 0
3 4 1 2011-08-18 17:16:15 1
3 4 0 2011-08-18 18:16:15 0
4 4 0 2011-08-18 19:16:15 0
Thanks