Skip to content
Advertisement

Interval to previous row

I would like to get the interval between the rows in my table.

When I use this query I get seconds from previous timestamp. But the result is only right when two timestamps is in the same minute.

How do I get the result in intervals?

Advertisement

Answer

you can use timestampdiff() function. I have used minute as unit here.

The unit should be one of the following : FRAC_SECOND (microseconds), SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, or YEAR. Unit is the measurement unit here in which you want to count the difference.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement