user1844859
user1844859

Reputation: 13

SQLite select numbers of album

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

Answers (2)

Satwik Nadkarny
Satwik Nadkarny

Reputation: 5135

SELECT artist, Count(album)
from MusicLibrary
group by artist
order by artist 

Upvotes: -1

juergen d
juergen d

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

Related Questions