Reputation: 207
I have an employee table and I want to count the number of employees that were hired on certain years. E.g 2010, 2013, 2014 and 2016..
So far I have something like:
SELECT COUNT(*) FROM employees WHERE hire_date IN(2010, 2013, 2014, 2016);
Upvotes: 0
Views: 1070
Reputation: 207
Okay I got it..
All I had to do was to extract a year from hire_date.
SELECT COUNT(*)
FROM employees
WHERE extract(YEAR FROM hire_date) IN (2003, 2004, 2006, 2008);
Upvotes: 5