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
(select max(`Time`) as MAXTIME, unitid from eventlog group by unitid) a
(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*