The catalog report

Boss exercise. The owner wants a per-album report: how many tracks each album has, its total duration in seconds, and its average track price — but only for albums with three or more tracks. Group by album_id, produce tracks, total_seconds and avg_price, filter with HAVING, and sort by album_id so the report reads top to bottom. The averages come out clean here, so no rounding needed.

Tables in this exercise
tracks
id title album_id genre_id duration_sec unit_price

Back to the chapter