Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

sql scenario on emp and dept

User_LCHKLOct 31 2014 — edited Nov 2 2014

Tables to be used:

1. scott.emp

2. scott.dept

For all deptno s in dept table if there is atleast 1 employee present in the emp table the output should be 1 else the output should be 0.

For example, deptno 40 in dept table do not have any employees present in the emp table so the output should be 0.

Desired output:

REQ

----------

         0

Now If I add a row into the emp table whose deptno is 40 ( Now For all deptnos in dept table there is atleast 1 emp record) , the output should be 1

       REQ

----------

         1

I have formed query as  below but not sure how to proceed furthur

select count(empno),deptno from emp group by deptno

This post has been answered by Frank Kulash on Nov 2 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 6 2023
Added on Oct 31 2014
12 comments
4,831 views