I have a employee table, and a vacations table where each row represents a day they took for vacation.
I want to get all employees who have taken more vacation days that their maximum vacation days value.
employees:
employeeId
maxVacationDays
vacations:
employeeId
date_vacation_day_taken
Query I have now:
SELECT e.*
FROM employees e
INNER JOIN vacations v ON (v.employeeId = e.employeeId)
WHERE e.isActive = true AND ( ???? > e.maxVacationDays)
So I need to get the count of rows from the vacations table for that employeeId.
Do I need a subquery for this?
(using sql2000)
Try this: