这个问题的答案:
显示每年雇用的运营商总数。
就是这样:
SELECT
COUNT(YEAR(HireDate)) AS 'Count',
YEAR(HireDate) AS 'Year'
FROM Operators
GROUP BY YEAR(HireDate);
但是我如何修改这个问题:
显示每年雇用多个运营商的运营商数量。
我试着做
WHERE Count >= 1
或
WHERE COUNT(YEAR(HireDate)) > 1
但没有任何效果。我做过研究CASE陈述,但是我找不到任何适合我需要做的事情,任何想法?
使用SQL Server 2008
答案 0 :(得分:1)
使用Having
子句
SELECT
COUNT(YEAR(HireDate)) AS 'Count',
YEAR(HireDate) AS 'Year'
FROM Operators
GROUP BY YEAR(HireDate)
HAVING Count >= 1;