Created
August 16, 2019 08:22
-
-
Save databraineo/99f947b70ee84b71645fd030276f1a27 to your computer and use it in GitHub Desktop.
Code examples for SQL 1x1 blog-article - 16
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
SELECT | |
Genre, | |
count(InvoiceId) AS Anzahl, | |
avg(AnzahlProKauf) AS MWAnzahlProKauf | |
FROM ( | |
SELECT | |
InvoiceId, | |
c.Name AS Genre, | |
count(a.TrackId) AS AnzahlProKauf | |
FROM InvoiceLine a | |
INNER JOIN Track b ON a.TrackId=b.TrackId | |
LEFT JOIN Genre c ON b.GenreId=c.GenreId | |
GROUP BY InvoiceId, b.GenreId | |
) | |
GROUP BY Genre | |
ORDER BY avg(AnzahlProKauf) DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment