I have two tables.
The first table, tblBasket is shown below,
Code ProductCode Price
SLK ABC 20
SLK DEF 30
SLK GHI 40
The second table, tblOrders is shown below,
Code ProductCode SaleId Amount
SLK ABC MMM 20
SLK DEF MMM 30
SLK GHI MMM 40
SLK ABC XXX 20
SLK DEF XXX 30
I need to check the tblBasket against tblOrders. The logic is that the basket is sold as a whole i.e. all 3 products with the code SLK must be sold together.
In the table tblOrder is a list of orders from different sales people (SaleId). Each SaleId where it has the code SLK should have the same 3 product codes as the basket. So in the above example saleId XXX is missing the product GHI. I need a query to flag this.
I tried the query below but it only return me 5 records it doesn't show me the missing product from saleId XXX even though I'm using a full outer join.
select * from tblBasket b full outer join tblOrders o
on b.Code = o.Code and b.ProductCode = o.ProductCode