+ 1
Query related to sql join, sub query and sql functions
Given 2 tables, Employee and department, we have to write a query to print the name of the department having heighest number of employees Employee table emp_id emp_name. salary dept_id 1067 John 3000 100 1057 Smith 5000 200 1143 Bob 4000 100 department table dept_id dept_name 100 Sales 200 IT 300 Marketing
2 Answers
+ 4
Select department.dept_name, employee.dept_id, count(employee.dept_id) as 'count' from employee join department on employee.dept_id = department.dept_id group by dept_id order by 'count' desc
The first record of this query would be the department with the most employees.
0
Thank you Hatsy Rei but only 1 record and only the department name is to be fetched