I have 3 tables like that:
- Employee_Table (Employee_Number, Employee_Name, Department_Number) With Employee_Number is PRIMARY KEY, Department_Number is FOREIGN KEY; - Employee_Skill_Table (Employee_Number, Skill_Code, Date Registered) With PRIMARY KEY (Employee_Number, Skill_Code); - Department (Department_Number, Department_Name) With PRIMARY KEY (Department_Number);
How can I specify
the departments which have >= 3 employees
Help me!
Advertisement
Answer
If you only need the departments that have more than 3 people try this query
SELECT d.Department_Name FROM Department d JOIN Employee_Table e ON e.Department_Number = d.Department_Number GROUP BY Department_Name HAVING COUNT(*) >= 3