Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2010

    Unanswered: timediff greater than some seconds

    Hi there

    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
    from points
    where truck=1883
    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:

    timestampdiff(second,date,@nexttime2) > 300

    thank you

  2. #2
    Join Date
    Aug 2005
    Try using Group By with Having clause.

    group by speed Having timestampdiff(second,date,@nexttime2) > 300

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts