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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

I just want to maintain data like an employee can belongs to 3 or more departments . We can resolve this by using composite key but it avoids normalization rules. So Can anyone tell me how can I maintain data.

1698


What is the cache hit ratio, what impact does it have on performance of an Oracle database and what is involved in tuning it?

1605


15. Display the item_cost and then truncate it to the nearest hundred, ten, unit, tenth and hundredth.

1699


What is archive log in Oracle?

595


What is rich query?

540






How remove data files before opening a database?

562


What is a Garbage Collection? and what is full recursive Garbage collection?

2386


How to assign data of the deleted row to variables?

579


How many types of tables are there in oracle?

574


What are joins, explain all types of joins?

1720


How do we create privileges in oracle?

586


How to get execution statistics reports on query statements?

567


What is the relation of a user account and a schema in oracle?

588


Explain the use of log option in exp command.

533


What is the oracle implicit cursor?

596