Hi friends...
I have a table like this,...
ID EMPName Dept Sal
1 a x 10000
2 b y 4000
3 c x 2500
4 d y 5000
5 e z 8500
I want to calculate the number of employee in department wise in single query ? Please explain ?
Thanks.........
Calculate number of employee
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Deepak DwijRank #348 · 7.2K reputationPosted Feb 11, 2012, 10:50 PM EST
create table record
(
ID int ,
EMPName varchar(25),
Dept varchar(20),
Sal int
)
Select Dept,count(*) as NumberOfEmployee from record group by Dept;
mahmoud saied9 reputationPosted Feb 11, 2012, 9:36 PM EST
You can try this:
SELECT DISTINCT EMPName FROM TABLE WHERE Dept LIKE 'X';Vineet Kumar SainiRank #257 · 9.8K reputationPosted Feb 11, 2012, 11:28 PM EST
Satyapriya NayakRank #47 · 31.5K reputationPosted Feb 11, 2012, 11:34 PM EST
SELECT Dept, COUNT(*) AS ' Number of employees'
FROM employee
GROUP BY Dept
ORDER BY Dept DESC
Thanks