Skip to content
Advertisement

SQL query – List albums where every song matches criteria

I am analyzing my music database which uses SQLite. I am trying to get a list of all albums where all the songs on that album having a rating of 10 or less.

Some contrived data for the example:

Using this example data, I would want my query to return “Presence” since all the songs on that album have a rating of 10 or less.

I know enough to get the list of all album names, or the list of all songs with a rating of 10 or less, but I don’t know enough to combine them – let alone when EVERY song on an album fits my criteria. I’m sure there’s just some key word that I don’t know about so don’t know what to research.

Thanks.

Advertisement

Answer

Group by album and take only those groups having a max rating of 10 for every song

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement