SELECT
t.subject AS `Ticket Subject`,
t.ticket_number AS `Ticket ID`,
d.name AS `Department`,
t.status AS `Ticket Status`,
t.name AS `Submitter Name`,
t.email AS `Submitter Email`,
t.`date` AS `Ticket Date`
FROM hb_tickets t
JOIN hb_ticket_departments d ON ( t.dept_id = d.id )
WHERE t.id IN (
    SELECT r.ticket_id FROM hb_ticket_replies r JOIN  `hb_ticket_replies_rating` rate ON (rate.reply_id=r.id)
    WHERE rate.rating<3
)
ORDER BY t.date ASC