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!

Not getting mismatch data

CostaFeb 21 2017 — edited Feb 21 2017

Hi all,

From the below two table, I want to find record from emp table where data in ename column is not matching with the f_name column of table List_name

if the text value from f_name column is matching with any of the deptno data, I want to exclude those dept.

e.g. Text 'UK02' from table List_name is available in deptno 101 from emp table. I don't want this type of record.

with emp as

(

select 101 as deptno, 'UK01' as ename, 900 as seq_num, 1000 as sal from dual union

select 101, 'UK02', 901, 2000 from dual union

select 102, 'UK001', 811, 2000 from dual union

select 102, 'UK0012', 812, 4000 from dual union

select 103, 'US001', 761, 3000 from dual union

select 103, 'US006', 762, 1000 from dual union

select 103, 'US007', 763, 4000 from dual union

select 104, 'RUS009', 201, 8000 from dual union

select 104, 'RUS001', 202, 7000 from dual union

select 105, 'AUS001', 501, 7000 from dual union

select 106, 'IND01', 321, 6000 from dual ),

List_name as

(

select 103 as id, 'US006' as f_name from dual union

select 106, 'IND01' from dual union

select 101, 'UK02' from dual union

select 107, 'SWE02' from dual )

select * from emp

where  ename not in (select f_name from list_name)

order by 1

My Output

    

DEPTNOENAMESEQ_NUMSAL
102UK0018112000
102UK00128124000
104RUS0012027000
104RUS0092018000
105AUS0015017000
This post has been answered by Solomon Yakobson on Feb 21 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 21 2017
Added on Feb 21 2017
5 comments
226 views