Created
November 19, 2012 18:26
-
-
Save clayenga/4112534 to your computer and use it in GitHub Desktop.
SQL question (total book prices for each genre)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| books: | |
| id | title | price | genre_id | |
| -------------------------------------------------- | |
| 1 | Gone With the Wind | 15 | 1 | |
| 2 | The Lord of the Rings | 30 | 2 | |
| 3 | The Hobbit | 10 | 2 | |
| 4 | Pride and Predjudice | 10 | 1 | |
| 5 | Complete Sherlock Holmes | 9 | 4 | |
| genres: | |
| id | name | | |
| ------------------------------ | |
| 1 | Romance | |
| 2 | Fantasy | |
| 3 | Comedy | |
| 4 | Mystery | |
| Write a query to get, for each genre (category), the sum of prices of books in that genre. |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Follow-up question, unless the original solution already does it:
How would you change the query so that it includes (Comedy, 0) in the results?