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
Member Avatar

diafol

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