Created
February 20, 2012 11:40
-
-
Save si/1868882 to your computer and use it in GitHub Desktop.
How to compare integers and dates on current and next records
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I have a table of petrol purchases, each recording the current odometer reading: | |
id | odometer | user_id | created | |
------------------------------- | |
2 | 63446 | 1 | 2012-01-15 11:27:57 | |
4 | 63835 | 1 | 2012-01-19 17:09:37 | |
5 | 64145 | 1 | 2012-01-28 13:02:08 | |
I want to return each row along with a distance and days lasted for each record (comparing the current record with the next record). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pretty much the point the entire dataset and indexes don't fit in memory anymore.