-- monthly-revenue summary query
SELECT d.dept_name, COUNT(*) AS total
FROM t_order o
JOIN t_user u ON o.user_id = u.user_id
JOIN t_dept d ON u.dept_id = d.dept_id
WHERE o.status = 'paid'
GROUP BY d.dept_name
having total > 5
