This should do it:
Notes:
1. It actually filters to the oldest three dates, rather than caches. This may produce more than three caches if they have the same placed date.
2. It will be noticeably slower than the previous query.
CODE |
code in (select code from caches as c1 where not(archived) and (select count(*) from caches as c2 where c1.county=c2.county and c2.placeddate < c1.placeddate and not(archived)) < 3) |
Notes:
1. It actually filters to the oldest three dates, rather than caches. This may produce more than three caches if they have the same placed date.
2. It will be noticeably slower than the previous query.