mysql - difference between timestamps in two consecutive rows in single table -
i want time difference between timestamps 2 consecutive rows of bellow table single query :
i tried query inefficient , giving server timeout...
class="lang-sql prettyprint-override">select t1.t_id id1, t2.t_id id2, t1.timestamp timestamp1, t2.timestamp timestamp2, timestampdiff(second, t1.timestamp, t2.timestamp) diff (select * `track`) t1, (select * `track` `t_id` != (select `t_id` `track` limit 1)) t2 ( t1.t_id - 1 ) = t2.t_id
join table itself, (haven't tried, idea)
select t1.t_id id1, t2.t_id id2, t1.timestamp timestamp1, t2.timestamp timestamp2, timestampdiff(second, t1.timestamp, t2.timestamp) diff track t1 bring together track t2 on (t2.t_id = t1.t_id - 1)
mysql sql
No comments:
Post a Comment