views:

22

answers:

1

Is it possible to build an unmatched data query using two tables with a tracking a unique value field and also another value in the row as well (that value will not be unique).

For example I want to track a unique customer code from an invoice on a new table, compared to last month's invoice. The non unique value would be a "product code" of what they purchased.

A customer code could appear multiple times depending on if they have purchased multiple product codes.

Any help is much appreciated.

A: 

This should do what you want:

SELECT Invoice.CustomerID
FROM Invoice LEFT JOIN PreviousInvoices
     ON (Invoice.Product = PreviousInvoices.Product) 
    AND (Invoice.CustomerID = PreviousInvoices.CustomerID)
WHERE PreviousInvoices.Product Is Null
BenV