SELECT cat, count(cat.id) AS am FROM Category cat, IN (cat.contributions) c WHERE c.user=:user GROUP BY cat.id ORDER BY am ---------------------------------- SELECT cat FROM Category cat, IN (cat.contributions) c WHERE c.user=:user GROUP BY cat.id HAVING count(cat.id) = max(count(cat.id))