-
-
Save toyeiei/eadb6ad73657e2da44ebdf935a746711 to your computer and use it in GitHub Desktop.
SQL for Beginner - Solutions Group By
This file contains 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
-- QUIZ 1 | |
-- count number of songs by genre | |
SELECT | |
genres.name, | |
COUNT(*) AS n | |
FROM genres | |
JOIN tracks | |
ON genres.genreid = tracks.genreid | |
GROUP BY genres.name; | |
-- QUIZ 2 | |
-- sum invoices by country | |
SELECT | |
customers.country, | |
SUM(total) AS sum_invoice | |
FROM customers | |
JOIN invoices | |
ON customers.customerid = invoices.customerid | |
GROUP BY customers.country; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment