SELECT totalAmount
FROM tbl
BETWEEN 'date1' AND 'date2'
GROUP BY DATE(date created)
ORDER BY DATE(date created)
This gives me the total amount for the day, which is in the table. But what I want is an incremental value compared to the previous record (not necessarily the previous day).
A table might look something like this:
totalAmount | date created
---------------------------------
1000 | 1st Jan
1001 | 2nd Jan
1003 | 3rd Jan
1008 | 15th Jan
So, when my request returns: 1000,1001,1003,1008.
I really want: (a number compared to the previous entry - but not within the BETWEEN date range to start my attempts), 1,2,5
ed209 source
share