SQL查询计数和不同年份

时间:2014-03-01 21:35:21

标签: mysql sql mysql-workbench

您好我正在尝试执行以下查询。基本上我试图统计1990年出生的所有音乐家。

SELECT COUNT(MusicianID), 
COUNT(DISTINCT CASE WHEN year(DateOfBirth)=1990)
FROM Musician

4 个答案:

答案 0 :(得分:1)

SELECT COUNT(MusicianID)
FROM Musician
WHERE YEAR(DateOfBirth)=1990

答案 1 :(得分:1)

Select count(musicianid)
from musician
Where year(date of birth) = 1990

答案 2 :(得分:1)

试试这个

 SELECT COUNT(MusicianID) As allmusicians
 FROM Musician
 WHERE year(DateOfBirth) = 1990

答案 3 :(得分:0)

这将有效:

SELECT COUNT(MusicianID)
FROM Musician
WHERE YEAR(DateOfBirth)=1990