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 |
Is there a combination of "like" and "in" in sql?
Difference between open_form and call_form in oracle.
How to execute the package in oracle?
What to do if the binary spfile is wrong for the default instance?
What is different types of joins?
How to establish administrator authentication to the server?
How to synchronize 2 schema's objects?
What is the effect of setting the value "CHOOSE" for OPTIMIZER_GOAL, parameter of the ALTER SESSION Command ?
How to set a transaction to be read only in oracle?
What happens if variable names collide with table/column names?
How are the index updates?
I have query like this. select dept_id, max_mark from stude_dept where min_mark= (select min(mini_mark) from stud_dept); How can i optimize this query. Can anyone help me with it