SELECT c.`name` AS course_name, COUNT(h.id) AS `quantity`
FROM `course` c
JOIN `history` h ON(h.course_id = c.course_id)
WHERE h.`status` = 1
GROUP BY c.`course_id`
select c.`name` AS course_name,
(select COUNT(*) from history where history.`course_id` = c.`course_id` AND history.`status` = 1) as quantity
from course c