You can use timestampdiff to find the difference between two points.
I'm not sure what you mean by "average." Average at the table? Average value per line?
If it is a table or a subset of rows:
select avg(timestampdiff(SECOND, startTimestamp, endTimestamp)) as avgdiff from table
The avg function works like any other aggregate function and responds to group by . For instance:
select col1, avg(timestampdiff(SECOND, startTimestamp, endTimestamp)) as avgdiff from table group by col1
This will give you average differences for each individual col1 value.
Hope this makes you point in the right direction!
source share