If you know how to select the last 4 registers, then use a Top 4 and order
by yourTimeField or whatever and the first query that it gets will be the
data from four minutes ago, although a more simple solution will be to take
the some sort of ID.
Yes, that would be the easy way but keep in mind, what if the rows weren't so easy...like:
Name title 3:55pm
Name title 4:02pm
Name title 4:25pm
Name title 4:55pm
Name title 4:58pm
and the time is 5:00pm
It's not guaranteed that the top 4 rows are within the last 5 minutes. So if I took the top 4 and sorted, in this example i'd get 4:02pm which is not in the last 5 minutes.
subqueries in the from clause are your freind.
from sometables join
(select min(datefield) mindatefield
where datefield >= dateadd(minute, -5, current_timestamp) sq on mindatefield = datefield
where datefield >= dateadd(minute, -5, current_timestamp
The exact syntax varies with the database.
You should also have a tie breaking plan.