rings 3 fantasy 2461.53 2 It 1 horror 960.26 3 Firestarter 1 horror 7416.70 4 Cell 1 horror 4202.73 5 Going postal 2 fantasy 8763.56 6 Foundation NULL Sci Fi 1209.59 7 Running man 1 Sci Fi 9757.26
R. Tolkien It Stephen King Firestarter Stephen King Cell Stephen King Going postal Terry Pratchet Running man Stephen King SELECT book.name, author.name AS "author" FROM book INNER JOIN author ON (author.author_id=book.author_id);
Cell Stephen King Running man Stephen King Going postal Terry Pratchet Lord of the rings J. R. R. Tolkien Foundation NULL SELECT book.name, author.name AS "author" FROM book LEFT JOIN author ON (author.author_id=book.author_id);
R. Tolkien It Stephen King Firestarter Stephen King Cell Stephen King Going postal Terry Pratchet Running man Stephen King NULL Paulo Coehlo SELECT book.name, author.name AS "author" FROM book RIGHT JOIN author ON (author.author_id=book.author_id);
Terry Pratchet 8763.56 SELECT author.name, SUM(book.earnings) AS earnings FROM author LEFT JOIN book USING (author_id) GROUP BY author.name HAVING SUM(book.earnings) < 10000
Paulo Coehlo 0.00 Terry Pratchet 8763.56 SELECT author.name, COALESCE(SUM(book.earnings), 0) AS earnings FROM author LEFT JOIN book USING (author_id) GROUP BY author.name HAVING COALESCE(SUM(book.earnings), 0) < 10000
J. R. R. Tolkien 2461.53 Stephen King 22336.95 Terry Pratchet 8763.56 SELECT author.name, SUM(book.earnings) AS earnings FROM author INNER JOIN book USING (author_id) GROUP BY author.name
books J. R. R. Tolkien 1 Stephen King 4 Terry Pratchet 1 SELECT author.name, COUNT(1) AS "published books" FROM author INNER JOIN book USING (author_id) GROUP BY author.name