Easy Aggregation Free

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_idtitleartist_idrelease_year
1Abbey Road11969
2Sgt. Pepper's Lonely Hearts Club Band11967
3The White Album11968
About the music sample database

Practice on your iPhone

Query Dojo for iPhone has 85 interview questions, timed mock interviews and a tile builder, so you can write queries without a keyboard.

Get the app

Keep going