This should work: SELECT b.code,c.code,COUNT(*) FROM borrowers WHERE DATE(dateenrolled) between <<Date between (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>> and b.code = <<Pick your branch|branches>> GROUP BY c.code