0

Hello Guys ..I have a question :

I have two tables employees and department .. employees table have forign key to depatment dept_id (pk) ..
i want to know which deapartment has maximum number of employees ... i have done little , but it give number of
employees in each depaertment ...

SELECT COUNT(emp_id)
FORM 
    employees
GROUP BY 
    dept_id
2
Contributors
1
Reply
9
Views
3 Years
Discussion Span
Last Post by diafol
0
SELECT COUNT(emp_id) AS cnt, dept_id
FROM 
    employees
GROUP BY 
    dept_id
ORDER BY cnt DESC
LIMIT 1

Use a join if you want the name of the dept returned

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.