【问题标题】:SQLite select numbers of albumSQLite 选择专辑编号
【发布时间】:2014-10-31 18:14:38
【问题描述】:

我想选择具有专辑数量的唯一艺术家。

在 MusicLibrary 表中,保存了单独的歌曲。 (标题、艺术家、专辑...)

我试过了:

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

但我知道歌曲的数量。

如果有人可以帮助我,我将非常感激

【问题讨论】:

  • select 中删除distinctalbum

标签: sql sqlite


【解决方案1】:

由于您保存了该表中的每首歌曲,因此您需要在计数中使用 distinct 来仅计算唯一专辑而不是每位艺术家的歌曲数量

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

【讨论】:

  • 非常感谢。我不知道我可以在 Count 中使用 distinct
【解决方案2】:
SELECT artist, Count(album)
from MusicLibrary
group by artist
order by artist 

【讨论】:

    猜你喜欢
    • 2015-01-31
    • 2011-10-21
    • 1970-01-01
    • 2011-03-13
    • 2021-03-12
    • 2017-07-25
    • 2015-02-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多