i have two tables
employee : employee_number employee_name salary divison_id
division : division_id division_name
How to Show division id, division name, number of employees working in each division that has the highest number of employees.
I want to have an outcome like this :
division_id division_name total_employee Z-100 | finance | 3
Advertisement
Answer
SELECT * FROM (SELECT e.division_id, d.division_name, Count(1) total_employee FROM employee e JOIN division d ON e.division_id = d.division_id GROUP BY e.division_id ORDER BY Count(1) DESC)a LIMIT 1