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!

How to return the value when the where conditions fails for the list in the "IN" operator ?

Ramesh SelvamAug 2 2019 — edited Aug 6 2019

Hi All,

I have the table as below:

create table emp_temp (employee_number varchar2(100),ename varchar2(100));

insert into emp_temp values (1,'ramesh');

insert into emp_temp values (2,'John');

insert into emp_temp values (3,'Peter');

The below sql query

select employee_number,'Found' from emp_temp

where employee_number in (1,2,3,4,5,6,7);

will return output as below

EMPLOYEE_NUMBER  FOUND

================== ========

1                                       Found

2                                       Found

3                                       Found

But Expected output is as below:

  

EMPLOYEE_NUMBERFOUND/NOT FOUND
1Found
2Found
3Found
4Not Found
5Not Found

6

7

Not Found

Not Found

Basically, I want to build the SQL query to display all the values in the "IN" operator and say found or not found.

Thanks,

Ramesh Selvam.

This post has been answered by mNem on Aug 2 2019
Jump to Answer
Comments
Post Details
Added on Aug 2 2019
15 comments
774 views