Reputation: 13
I want select the uniques artist with the numbers of albums.
In the MusicLibrary table, the individual songs are saved. (title, artist, album ...)
I have tried:
SELECT distinct artist, album, Count(*) from MusicLibrary group by artist order by artist
but I get the number of songs.
I would be very grateful if anyone can help me
Upvotes: 0
Views: 441
Reputation: 5135
SELECT artist, Count(album)
from MusicLibrary
group by artist
order by artist
Upvotes: -1
Reputation: 204854
Since you save every song in that table you need to use distinct
in your count to only count unique albums and not the number of songs for every artist
SELECT artist, Count(distinct album) as albums
from MusicLibrary
group by artist
order by artist
Upvotes: 2