
SELECT COUNT(DISTINCT t.`id`) AS `Tickets answered`,  r.name AS `Staff Name`
FROM hb_tickets t
JOIN hb_ticket_replies r ON (r.ticket_id=t.id)
WHERE
 r.type='Admin'
 AND
 r.`date` > :date_bottom
AND
 r.`date` < :date_top
 AND
 DAYOFWEEK(r.`date`) IN (1,7)
GROUP BY
r.replier_id
)
