Skip to main content
Solved

SQL Query Tool/Quick Report: EXCEPTION JOIN - Oracle equivalent


Forum|alt.badge.img+10
  • Sidekick (Customer)
  • 119 replies

Quick question, on other platforms there’s an EXCEPTION JOIN that is exclude rows from Table A that aren’t in TABLE B. What is the equivalent in Orace/IFS?

We created a custom table of customers to exclude. So when we report on CustomerOrders we only want orders that don’t have a Customer# in Table B.

select 
order_no,
part_no,
base_sale_unit_price

from CustomerOrderLine  col

EXCEPTION JOIN Exclude_Customers_Cfv  ec
   on ec.cf$_customer_id = col.customer_id

Where col.contract = 'W'

 

Best answer by dhlelk

Hi @DevBob,

I hope I read your requirement correctly :relieved:
You could exclude the results using a sub query with a NOT EXISTS predicate as follows,

SELECT order_no,
       part_no,
       base_sale_unit_price
FROM   CustomerOrderLine col
WHERE  col.contract = 'W'
AND    NOT EXISTS (SELECT 1
                   FROM   Exclude_Customers_Cfv ec
                   WHERE  ec.cf$_customer_id = col.customer_id)
;

Cheers !
Dhananjaya.

View original
Did this topic help you find an answer to your question?
This topic has been closed for comments

5 replies

dhlelk
Superhero
Forum|alt.badge.img+15
  • Superhero
  • 200 replies
  • Answer
  • March 3, 2021

Hi @DevBob,

I hope I read your requirement correctly :relieved:
You could exclude the results using a sub query with a NOT EXISTS predicate as follows,

SELECT order_no,
       part_no,
       base_sale_unit_price
FROM   CustomerOrderLine col
WHERE  col.contract = 'W'
AND    NOT EXISTS (SELECT 1
                   FROM   Exclude_Customers_Cfv ec
                   WHERE  ec.cf$_customer_id = col.customer_id)
;

Cheers !
Dhananjaya.


Forum|alt.badge.img+10
  • Author
  • Sidekick (Customer)
  • 119 replies
  • March 3, 2021

That worked! Thx very much!      :grinning:     :thumbsup:


dhlelk
Superhero
Forum|alt.badge.img+15
  • Superhero
  • 200 replies
  • March 4, 2021
DevBob wrote:

That worked! Thx very much!      :grinning:     :thumbsup:

Hi @DevBob,

You are welcome and I'm happy to help 😊

Cheers !
Dhananjaya.


durette
Superhero (Customer)
Forum|alt.badge.img+19
  • Superhero (Customer)
  • 526 replies
  • March 16, 2021

Alternatively, you may consider the LEFT JOIN syntax. I think it makes the queries cleaner than EXISTS clauses.

   SELECT col.order_no,
          col.part_no,
          col.base_sale_unit_price
     FROM CustomerOrderLine col
LEFT JOIN Exclude_Customers_Cfv ec
       ON ec.cf$_customer_id = col.customer_id
    WHERE col.contract = 'W'
      AND ec.cf$_customer_id IS NULL;

 


Forum|alt.badge.img+10
  • Author
  • Sidekick (Customer)
  • 119 replies
  • March 17, 2021

thx- that looks very polished!  :rofl:


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings