|You have a table of sequential times, and you're asked to report the average time interval between them in seconds.
Assuming table |
Select TimeStampDiff(SECOND, Min(ts), Max(ts) ) / ( Count(DISTINCT(ts)) -1 ) FROM tNot sure of the formula?
1. The mean distance between consecutive rows is the sum of distances between consecutive rows, divided by the number of consecutive rows.
2. The sum of differences between consecutive rows is just the distance between the first row and last sorted row (assuming they are sorted by timestamp).
3. The number of consecutive rows is the total number of rows - 1.