Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sureshsmanian
Starting Member
31 Posts |
Posted - 2009-10-18 : 02:34:13
|
| HiI have two tables. Employee(Eno -- PK, Ename, Deptno -- FK refers Dept table, Gender)Dept (Deptno -- PK, Deptname, Mgrno)Question : I need a sql command to display the Deptno, Deptname and number of male employees in each department. Deptno Deptname MaleCount ------ -------- --------- ---- ------- ------ Thanks in advanceRegardsSSM |
|
|
fanzhouqi
Starting Member
4 Posts |
Posted - 2009-10-18 : 09:41:37
|
| select Deptno ,Deptname , MaleCount = count(1)from Dept a inner join Employee b on a.Deptno = b.Deptno where b.Gender = 'Male'group by Deptno ,Deptname |
 |
|
|
sureshsmanian
Starting Member
31 Posts |
Posted - 2009-10-19 : 03:41:45
|
| Thanks a lot. it is working fine.RegardsSSM |
 |
|
|
sureshsmanian
Starting Member
31 Posts |
Posted - 2009-10-19 : 03:43:31
|
| Thanks a lot. it is working fine.RegardsSSM |
 |
|
|
|
|
|