Show each author's name and how many distinct books they have (named book_count), ordered by book_count descending then name. This is the normalized link in action.
Show each author's name and how many distinct books they have (named book_count), ordered by book_count descending then name. This is the normalized link in action.
Answer
SELECT a.name, COUNT(b.id) AS book_count FROM authors a LEFT JOIN books b ON b.author_id = a.id GROUP BY a.name ORDER BY book_count DESC, a.name;