The album sales report

Two CTEs, chained. First track_sales: units and revenue per track from invoice_lines. Then album_sales, which reads track_sales and rolls it up per album. Show title, units and revenue for every album — albums with no sales must appear with 0, not disappear.

Tables in this exercise
albums
id title artist_id release_year
tracks
id title album_id genre_id duration_sec unit_price
invoice_lines
id invoice_id track_id quantity unit_price

Back to the chapter