The query works very well, thanks. I added a distinct to prevent redundant checking (actually I dont know if it prevents redundant checking, but at least removes them from display):
SELECT
distinct(f1.datesold) AS d1,
(SELECT MIN(f2.datesold) FROM foo f2 WHERE f2.datesold > f1.datesold) AS d2
FROM foo f1
HAVING d1 < d2 - INTERVAL 5 DAY
ORDER BY d1;
Is there anyway to optimize the query to run quicker? It takes minutes to run it on a table with 100,000 entries, maybe 2500 unique dates.
Thanks again.