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
Crie um índice composto em
(session_id, datetime, progress)
para que isso funcione rápido.