If your use case is pagination of an aggregate query e.g.
SELECT p.name, COUNT(c.id) FROM Person p LEFT JOIN p.cats c GROUP BY p.name
Counting the number of results is a matter of counting the distinct groups.
SELECT COUNT(DISTINCT p.name) FROM Person p