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



Given two table employee and department EMP ---------------- empid deptid(fk) Dept ---..

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

Given two table employee and department EMP ---------------- empid deptid(fk) Dept ---..

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

Post New Answer

More Oracle General Interview Questions

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?

7 Answers   IBM,


How do we get field detail of a table?

0 Answers  


There are three tables : E : EID,ENAME D : DID,DNAME empdept : eid, did select the employees who doesn't belong to any dep

4 Answers   Microsoft,


How to insert multiple rows with one insert statement in oracle?

0 Answers  






How to invoke the data pump export utility?

0 Answers  


How to speed up webrick?

0 Answers  


How to create index-by table in oracle?

3 Answers  


What do you understand by database schema and what does it hold?

0 Answers  


What is the difference between a primary key & a unique key?

0 Answers  


How do I decide when to use right joins/left joins or inner joins or how to determine which table is on which side?

0 Answers  


What is a heap related to database ?

1 Answers   TCS, University of Edinburgh,


Categories
  • Oracle General Interview Questions Oracle General (1789)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)