MR
Nice article! The query can also be written as: SELECT actor_name AS actorName, Sum(CASE WHEN acr.rating_name = 'excellent' THEN 1 ELSE 0 END) AS total_excellent, Sum(CASE WHEN acr.rating_name = 'better' THEN 1 ELSE 0 END) AS total_better, Sum(CASE WHEN acr.rating_name = 'good' THEN 1 ELSE 0 END) AS total_good FROM actor_survey acs LEFT JOIN actor_rating acr ON acs.rating_id = acr.id GROUP BY actorname But I understand the posted query is for the sake of the purpose of this article series. :D
