3 ms·
My solution: SELECT authors.name, SUM(sales.price) FROM authors INNER JOIN books ON authors.id = books.author_id INNER JOIN sales ON books.id =
by hartleybrody 13y ago
My solution:
SELECT authors.name, SUM(sales.price) FROM authors
INNER JOIN books ON authors.id = books.author_id
INNER JOIN sales ON books.id = sales.book_id
WHERE sales.date >= Nov 2013 AND sales.date < Dec 2013
GROUP BY authors.name
Although a coworker pointed out that inner joins would drop authors who haven't written books, and books that have no sales. If you want to include all of those, then use LEFT OUTER JOIN instead of INNER JOINs.