365 Days of Daily Coding: Day 51
I think I might need a break from work considering my demotivation these days. It’s not easy to sustain the working mood everyday. I enjoy being indoors but this lockdowns have really gotten the best of me.
Today I solved a medium challenge. At first I wasn’t able to pass but I figured out that I had to use LEFT JOIN instead of INNER JOIN.
SELECT actor_category, COUNT(actor_category) AS count
FROM (
SELECT a.actor_id, COUNT(f.film_id) AS counts,
CASE
WHEN COUNT(f.film_id) >= 30 THEN 'productive'
WHEN COUNT(f.film_id) <30 THEN 'less productive'
END actor_category
FROM actor a LEFT JOIN film_actor f
ON a.actor_id = f.actor_id
GROUP BY a.actor_id) AS k
GROUP BY actor_category;

Leave a comment