SQL interview question: Group Years by Decade
Group Albums by Decade
The music team wants to analyze catalog distribution across decades.
Count how many albums were released in each decade.
Return decade (as a number like 1960, 1970) and album_count. Order by decade.
Skills: integer division and grouping
Tables
albums 18 rows
- album_id integer PK
- title text
- artist_id integer → artists
- release_year integer
| album_id | title | artist_id | release_year |
|---|---|---|---|
| 1 | Abbey Road | 1 | 1969 |
| 2 | Sgt. Pepper's Lonely Hearts Club Band | 1 | 1967 |
| 3 | The White Album | 1 | 1968 |