HI,
don't shoot me if my example query doesn't work, as I'm more experienced with Oracle than Sql Server. But to me it looks like you need to use the NOT EXISTS clause. The logic is that you want to
exclude any tubedestination where there was
activity the last hour? Then I would suggest something like this:
Code:
SELECT TubeDestination, MAX(TimeSent) AS TimeSent
FROM Table1 t1
WHERE
not exists (
SELECT 1
FROM Table1 t2
WHERE
t2.TubeDestination = t1.TubeDestination and
t2.TimeSent > dateadd(hh,-1,getdate())
)
GROUP BY TubeDestination
Hope this helps.