The answer to this question:
Display the total number of operators hired each year.
is this:
SELECT
COUNT(YEAR(HireDate)) AS 'Count',
YEAR(HireDate) AS 'Year'
FROM Operators
GROUP BY YEAR(HireDate);
But how would I modify that for this question:
Display the number of operators hired in each year where more than one operator was hired.
I tried to do
WHERE Count >= 1
or
WHERE COUNT(YEAR(HireDate)) > 1
but nothing worked. I did research CASE statements but I couldn't find anything suiting what I need to do, any idea?
Using SQL Server 2008
Use Having clause
SELECT
COUNT(YEAR(HireDate)) AS 'Count',
YEAR(HireDate) AS 'Year'
FROM Operators
GROUP BY YEAR(HireDate)
HAVING Count >= 1;
Read More
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With