I have a query that returns the diffrence time from two dates but I would like to get also in the same query those results that are greater that for example 300 seconds.
Here it is my query:
select truck, date,speed,heigh, timediff(@nexttime,date) as diffrence ,timestampdiff(second,date,@nexttime2) as seconds,
(@nexttime:=date) as Next,(@nexttime2:=date) as Next,x,y
and date>= '2011-05-21 00:00:00'
and date<= '2011-05-21 12:44:59'
order by date desc
What I get now is all the records with the "difference field" calculated but I can't get those greater than 300 seconds even using in the where clause: