Which Department has MOST NUMBER of employees?
Answers were Sorted based on User's Feedback
Answer / sts
Select Deptno,Count(*) from Emp Group By Deptno having Count(*)=(SELECT max (count(*)) FROM EMP GROUP BY DEPTNO);
| Is This Answer Correct ? | 24 Yes | 13 No |
Answer / mady
In SQL Server / MS Access:
==========================
select top 1 department_name
from EMPLOYEES
join DEPARTMENTS
on EMPLOYEES.department_id=DEPARTMENTS.department_id
group by department_name
order by count(*) desc;
In My SQL:
============
select department_name
from EMPLOYEES
join DEPARTMENTS
on EMPLOYEES.department_id=DEPARTMENTS.department_id
group by department_name
order by count(*) desc
limit 1;
| Is This Answer Correct ? | 24 Yes | 29 No |
Answer / ns
SELECT count(*), department_id
FROM employees
GROUP BY department_id
HAVING count(*) =
(SELECT max(count(*))
FROM employees
GROUP BY department_id)
| Is This Answer Correct ? | 40 Yes | 46 No |
Answer / shibashis
Select d.deptname,count(*) as cnt
from employee e inner join dept d
On e.deptid=d.deptid
group by d.deptname
having cnt in (
select max(cnt) from
(SELECT deptid ,count(*) as cnt FROM employee GROUP BY deptid )
)
order by d.deptname
;
| Is This Answer Correct ? | 1 Yes | 7 No |
Answer / senthil
select column_name,count(*)from table_name group by
column_name having count(*)=(select max(count(*)) from
table_name group by column_name);
PLZ Contact Any Queries (raja.prem86@gmail.com)
| Is This Answer Correct ? | 20 Yes | 27 No |
Answer / aswini
select dept_id from emp group by dept_id having count(*)=(Select max(count(*)) From Emp group by dept_id)
| Is This Answer Correct ? | 2 Yes | 14 No |
Answer / nannesaheb
SQL> Select Deptno,Count(*) from Emp
Group By Deptno
Having Count(*)=(Select Max(Count(*)) From Emp);
--If Any Queries Contact Me at nannesaheb.c@gmail.com
--Nannesaheb
| Is This Answer Correct ? | 8 Yes | 26 No |
what is difference between DBMS and RDBMS?
how to get count of tables in particular database in Oracle?
How to create a new table in oracle?
How different is ms access and oracle?
find out the third highest salary?
92 Answers CIPL, Cyber Shot, HCL, Hewitt, IBM, JPMorgan Chase, Orion, Verizon,
How do I call oracle stored procedures that take no parameters?
What is data file?
What query tells you how much space a tablespace named test is taking up, and how much space is remaining?
What are the oracle differences between nvl and coalesce
How to test null values?
How to delete all rows a table in oracle?
Explain what are the advantages of views?