SELECT COUNT(*)
FROM (
SELECT session_id
FROM formation_page_hits
WHERE progress IN (2, 4, 7)
AND datetime >= '2011-03-23'
AND datetime < '2011-03-24'
GROUP BY
session_id
HAVING COUNT(DISTINCT progress) = 3
) q
Buat indeks gabungan di (session_id, datetime, progress)
agar ini bekerja dengan cepat.