Fixing issue with non grouped count queries