Given two table employee and department
EMP
----------------
empid deptid(fk)
Dept
---------------------
deptid(pk) deptname
que-Write a query to find count of employee in each
department.
Expected Output-
deptid countofEmployee
---------------------------
10 57
20 20
30 15
Answers were Sorted based on User's Feedback
Answer / anithaletchumi
select d.deptid,count(e.empid) as countofEmployee from
department d left outer join employee e on
d.deptid=e.deptid group by d.deptid
Is This Answer Correct ? | 4 Yes | 2 No |
Answer / ajit
select d.deptno, count(e.deptno) total
from emp e, dept d
where e.deptno(+) = d.deptno
group by d.deptno;
Is This Answer Correct ? | 0 Yes | 0 No |
Query to get max and second max in oracle in one query ?
34 Answers CTS, Keane India Ltd, TCS, Wipro,
difference between procedures and function?
How do we get field detail of a table?
There are three tables : E : EID,ENAME D : DID,DNAME empdept : eid, did select the employees who doesn't belong to any dep
How to insert multiple rows with one insert statement in oracle?
How to invoke the data pump export utility?
How to speed up webrick?
How to create index-by table in oracle?
What do you understand by database schema and what does it hold?
What is the difference between a primary key & a unique key?
How do I decide when to use right joins/left joins or inner joins or how to determine which table is on which side?
What is a heap related to database ?
1 Answers TCS, University of Edinburgh,