From 32e9f7f56db58e75d4a358f728e4c8cdb14ab0f5 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Sun, 26 Jul 2020 15:53:07 +0100 Subject: [PATCH] Add query for the productive directors Show the movies from directors that appear more than once in the list. --- todo-lists/imdb/scratch.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/todo-lists/imdb/scratch.sql b/todo-lists/imdb/scratch.sql index 9ddba8e91..6835c73bd 100644 --- a/todo-lists/imdb/scratch.sql +++ b/todo-lists/imdb/scratch.sql @@ -48,3 +48,18 @@ WHERE isCartoon = true; SELECT * FROM Movies WHERE isCartoon = true AND requiresSubtitles = false; + +-- show the movies from the directors that show up on the list more than once. +SELECT * +FROM Movies +WHERE director in ( + SELECT director + FROM ( + SELECT director, COUNT(*) as num + FROM Movies + GROUP BY director + HAVING num > 1 + ORDER BY num DESC + ) +) +ORDER BY director, rating DESC, year DESC;