The catalog team wants a per-genre breakdown of tracks across the 3 most common media types, using conditional aggregation.
Return GenreId, Name, MPEGCount (MPEG audio file), ProtectedAACCount (Protected AAC audio file), AACCount (AAC audio file), and TotalTracks, ordered by GenreId ascending.
Note: video/TV genres (Science Fiction, TV Shows, etc.) are entirely a fourth media type ('Protected MPEG-4 video file') not pivoted here, so their three count columns will be 0 while TotalTracks is nonzero -- expected, not a bug.
| Column | Type |
|---|---|
| GenreId | INTEGER (Primary Key) |
| Name | TEXT |
Ready 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.