For genres present in every calendar year of available data, compute year-over-year revenue growth.
| 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 |
| Column | Type |
|---|---|
| InvoiceId | INTEGER (PK) |
| CustomerId | INTEGER (FK) |
| InvoiceDate | TIMESTAMP NOT NULL |
| BillingCountry | TEXT |
| Total | NUMERIC(10,2) NOT NULL |
LAG() partitioned by genre to get the prior year revenueGenre, Year, Revenue, PrevYearRevenue, YoY_Growth_Pct (rounded to 2; NULL when no prior year)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.