我想选择具有相册数量的唯一艺术家。
在MusicLibrary表格中,会保存各首歌曲。 (标题,艺术家,专辑......)
我试过了:
SELECT distinct artist, album, Count(*) from MusicLibrary group by artist order by artist
但是我得到了歌曲的数量。
如果有人能帮助我,我将非常感激
答案 0 :(得分:2)
由于您保存该表格中的每首歌曲,因此您需要在计数中使用distinct
来计算唯一的专辑,而不是每位艺术家的歌曲数量
SELECT artist, Count(distinct album) as albums
from MusicLibrary
group by artist
order by artist
答案 1 :(得分:-1)
SELECT artist, Count(album)
from MusicLibrary
group by artist
order by artist