For each genre, find the top 3 tracks by units sold.
| Column | Type |
|---|---|
| InvoiceLineId | INTEGER (PK) |
| InvoiceId | INTEGER (FK) |
| TrackId | INTEGER (FK) |
| UnitPrice | NUMERIC(10,2) NOT NULL |
| Quantity | INTEGER NOT NULL |
| Column | Type |
|---|---|
| TrackId | INTEGER (PK) |
| Name | TEXT NOT NULL |
| AlbumId | INTEGER (FK → Album) |
| MediaTypeId | INTEGER (FK → MediaType) |
| GenreId | INTEGER (FK → Genre) |
| Composer | TEXT |
| Milliseconds | INTEGER NOT NULL |
| Bytes | INTEGER |
| UnitPrice | NUMERIC(10,2) NOT NULL |
| Column | Type |
|---|---|
| GenreId | INTEGER (PK) |
| Name | TEXT |
InvoiceLine.Quantity per (Track, Genre)UnitsSold descending, breaking ties by TrackName ascendingGenre, TrackName, UnitsSold, GenreRankReady to take your skills to the next level? Enroll in our comprehensive Data Analyst Career Track to master SQL, Python, Excel, and Power BI.
Run your code to see the result here.