Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Query to compare two subsets from two queries
    primarykey
    data
    text
    <p>I need to compare all orders of type 728 to all of the other order types for each customer to find any customers where order types 728 have any items that are not in at least one other order type, or if any of the other order types have any items that are not in order type 728 for that customer.</p> <pre><code> Customers OrderTypes Items Customer 2245 OrderType 728 Item PT Item Custom Item Special OrderType 234 Item PT Item Custom OrderType 300 Item PT Item Custom OrderType 999 Item PT </code></pre> <p>I have queried so that I have a table variable of the order types of 728 (with Customer and order type data), @Items_728</p> <p>I have queried so that I have a table variable of the order types of everything but 728 (with Customer and order type data), @Items_Not728</p> <p>I want to get a resultset of all 728 order types per customer that have items not in other order types for that customer.</p> <p>Example: OrderType 728 has an Item Special not found in at least one other OrderType</p> <p>I want to get a resultset of all order types per customer that have items not in the 728 order type.</p> <p>Example: OrderType 999 does not have Item Custom</p> <p>I would like to do this as a set-based operation, rather than creating a cursor and walking it customer by customer, manually comparing sets of orders, noting any differences and saving each customer number. That seems terribly inefficient and dirty.</p> <p>I have looked through other StackOverflow questions but have not noted anything that seemed to look like this. Any helpful suggestions would be very much appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload