Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2003
    Posts
    123

    Unanswered: Long time no SQL

    Seems like I'm a bit rusty at SQL... I can't see why this code doesnt work.

    I have an eventlog in my system that registers all events from various units.
    What I want to do is select all units that hasn't had any events in a specific interval. Say 2 hours.

    First I created a query that selects max(time) from the log, I then want to select just the units with no events in the interval. It returns none although I know there should be some rows if I look at the inner query.

    select a.MAXTIME, a.unitid
    from
    (select max(`Time`) as MAXTIME, unitid from eventlog group by unitid) a
    where
    (a.MAXTIME < (Now() - INTERVAL 120 MINUTE))

    I'd very much lie this task to be done in ONE query, but maybe it isn't possible?

    EDIT: OMG.... I had written the wrong date for today in the time column.... I had written tomorrow. Query works ok if I changed the date!
    *puts on funny hat and sits in corner ashamed*
    Last edited by oneleg_theone; 07-12-07 at 06:16.

  2. #2
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    LOL, it happens

Posting Permissions

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