QUOTE (PPete @ August 27, 2013 04:04 pm) |
Yes, the database is complete, and I think I found out the problem: Each county which oldest cache is already archived is not filtered. (the oldest, not archived cache of this county should be filtered instead) |
Ah yes, good point!

(I have no archived caches in my current database so hadn't checked that

Try this tweak:
CODE |
code in (select code from caches as c1 where not(archived) and not exists (select 1 from caches as c2 where c1.county=c2.county and c2.placeddate < c1.placeddate and not(archived))) |