0

I have the following two tables:

ITEM (Item#, Item_Name, Unit_Price)

ORDER_ITEM (Order#, Item#, Qty)

Now, how do I list the items that have never been ordered by using the MINUS operator?

MDCCL
  • 8,530
  • 3
  • 32
  • 63
stranger
  • 193
  • 3
  • 4
  • 13

2 Answers2

4

How about:

select item# from item
minus
select item# from ORDER_ITEM
CalZ
  • 934
  • 4
  • 10
2

This is a bit long to add as a comment to @CalZ answer so I create another answer:

select item#, Item_Name from item
minus 
select i.item#, i.Item_Name 
from item i
join order_item oi
    on i.item# = oi.item#

in the second leg of the minus, we construct a new relation using a join between item and order_item that we can subtract from item.

Lennart - Slava Ukraini
  • 23,842
  • 3
  • 34
  • 72