Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 445

Time Difference between query result rows in SQLite: How To?

$
0
0

Consider the following reviews table contents:

CustomerName    ReviewDTDoe,John        2011-06-20 10:13:24Doe,John        2011-06-20 10:54:45Doe,John        2011-06-20 11:36:34Doe,Janie       2011-06-20 05:15:12

The results are ordered by ReviewDT and grouped by CustomerName, such as:

SELECT  CustomerName,  ReviewDTFROM  ReviewsWHERE  CustomerName NOT NULLORDER BY CustomerName ASC, ReviewDT ASC;

I'd like to create a column of the time difference between each row of this query for each Customer... rowid gives the original row, and there is no pattern to the inclusion from the rowid etc...

For the 1st entry for a CustomerName, the value would be 0. I am asking here incase this is something that can be calculated as part of the original query somehow. If not, I was planning to do this by a series of queries - initially creating a new TABLE selecting the results of the query above - then ALTERING to add the new column and using UPDATE/strftime to get the time differences by using rowid-1 (somehow)...


Viewing all articles
Browse latest Browse all 445

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>