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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Exclude records based on types

mist123Aug 27 2024 — edited Aug 27 2024

Hi All,

This is the request I asked earlier but we have made some changes.

https://forums.oracle.com/ords/apexds/post/delete-records-4866

Hi All,

Oracle 11.2

I have this data in the table.

SELECT 'AAA_1' Item,
       111     Dept_no,
       1010    sup_deptno,
       'Transfer' dept_type
FROM   dual
UNION ALL
SELECT 'BBB_1' Item,
       NULL    Dept_no,
       2020    sup_deptno,
       'External' dept_type
FROM   dual
UNION ALL
SELECT 'CCC_1' Item,
       3030    Dept_no,
       3030    sup_deptno,
       'Transfer' dept_type
FROM   dual
UNION ALL
SELECT 'DDD_1' Item,
       NULL    Dept_no,
       NULL    sup_deptno,
       'Inter' dept_type
FROM   dual 
UNION ALL
SELECT 'FFF_1' Item,
       4040    Dept_no,
       NULL    sup_deptno,
        'Misc' dept_type
FROM   dual
UNION ALL
SELECT 'GGG_1' Item,
       5050    Dept_no,
       NULL    sup_deptno,
        'Inter' dept_type
FROM   dual;

If dept_no and sup_deptno are same then dont display this row
if dept_no and sup_deptno are NULL then dont display this row
if dept_no is not null and sup_deptno is NULL and  dept_type='Misc' then dont display this row

Current output

expected output

@solomon-yakobson @frank-kulash @cookiemonster76

This post has been answered by Frank Kulash on Aug 27 2024
Jump to Answer
Comments
Post Details
Added on Aug 27 2024
5 comments
179 views