Exercise 1.b solution notes

Here is one way to solve the problem:

SELECT name, count(*) AS total
FROM people
JOIN credits  ON credits.person_id = people.id AND type = 'writer'
JOIN genres ON genres.movie_id = credits.movie_id AND genre = 'Drama'
WHERE name NOT IN (
   SELECT name
   FROM people
   JOIN credits ON credits.person_id = id and type = 'writer'
   JOIN genres ON genres.movie_id = credits.movie_id AND genre <> 'Drama'
)
GROUP BY name
ORDER BY total desc, name
LIMIT 10;

This query produces the output:

NAME                    TOTAL
----------------------  -----
Barber, Lynn (II)           1
Beaufoy, Simon              1
Cretton, Destin Daniel      1
Donoghue, Emma (I)          1
Jenkins, Barry (III)        1
Koreeda, Hirokazu           1
Lee, Chang-dong             1
Lonergan, Kenneth           1
McCraney, Tarell Alvin      1
Mungiu, Cristian            1