SELECT SUBSTRING_INDEX(l.`action`,'member','-1') AS `Staff member`, COUNT(t.`id`) AS `Total closed`, DATE(l.`date`) AS `Date` FROM `hb_tickets` t JOIN `hb_tickets_log` l ON (l.ticket_id=t.id) WHERE l.date>= :date_bottom AND l.date<= :date_top AND t.status='Closed' AND l.action LIKE '%to "Closed" by%' GROUP BY `Date`, `Staff member`