Use the right query to do aggregate counts