Hi,
I have been playing around with B4Android and a SQLite database and was wondering how I would go about creating a query which would return the difference between dates of adjacent table rows?
So in the example below I would want to be able to calculate the number of days since the previous order for each order date (so the DaysSince column).
Ok, I figured it out for myself, the SQL statement required would be:
B4X:
"SELECT q.Test, q.Date, strftime('%J',q.Date) - strftime('%J',coalesce((select r.Date from Result as r WHERE r.Date < q.Date ORDER BY r.Date DESC limit 1), q.Date)) as DaysSince FROM Result as q WHERE q.Test NOT NULL ORDER BY q.Test ASC, q.Date ASC;"
The above SQL gave me what I needed, but for educational purposes I would be interested in being given a few pointers of how to calculate the difference using Basic4android code.