When I tried the solution a_horse_with_no_name, I had to delete the section "partition by id" to get the result (I use PG 9.2)
SELECT id, total, total - lag (total) over (order by timestamp_column) as diff_since_last FROM the_table_with_no_name
source share