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.........
Loading

Deepak DwijPosted Feb 12, 2012, 3:50 AM
create table record
(
ID int ,
EMPName varchar(25),
Dept varchar(20),
Sal int
)
Select Dept,count(*) as NumberOfEmployee from record group by Dept;
Satyapriya NayakPosted Feb 12, 2012, 4:34 AM
SELECT Dept, COUNT(*) AS ' Number of employees'
FROM employee
GROUP BY Dept
ORDER BY Dept DESC
Thanks
Vineet Kumar SainiPosted Feb 12, 2012, 4:28 AM
mahmoud saiedPosted Feb 12, 2012, 2:36 AM
You can try this: