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?
How about:
select item# from item
minus
select item# from ORDER_ITEM
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.
Item_Name
without a join to item
?
Aug 10, 2017 at 13:47