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

various types of hints and their usage

2139


How many categories of data types?

582


How to rename an index in oracle?

628


How to start a new transaction in oracle?

599


what is the difference between functional dependecy and multilevel dependency?

2002






How to get a list of all background sessions in the database?

556


How to rename an index?

597


How to create a new view in oracle?

628


How to assign values to variables?

588


How to assign query results to variables?

599


Can you tell me how to add new column in existing views?how?How is possible?

948


What do you mean by merge in oracle and how can you merge two tables?

535


What do you understand by a database object? Can you list a few of them?

617


What are the differences between primary key and unique key?

528


How to rename an existing table?

619