Subject | Tough sql question |
---|---|
Author | Bob Murdoch |
Post date | 2003-10-29T12:37:03Z |
I'm hoping someone can help with a tough question. I've been trying to
come up with a single query to provide this answer, but have been unsuccessful:
Given a table of orders and line items, I want to create a result set
showing those orders than contain only line items matching a specific
list. For example:
Order 1:
Apple
Orange
Order 2:
Apple
Orange
Banana
If the target list was [Apple,Orange], only Order 1 would meet the criteria
(because order 2 contained something not in the list). If the target list
was [Apple, Orange, Banana], both orders would match. If the target list
was [Banana], either of the orders would match.
I'm not opposed to creating a view and selecting from that.
Off to dowse the flames coming from my ears,
Bob M..
come up with a single query to provide this answer, but have been unsuccessful:
Given a table of orders and line items, I want to create a result set
showing those orders than contain only line items matching a specific
list. For example:
Order 1:
Apple
Orange
Order 2:
Apple
Orange
Banana
If the target list was [Apple,Orange], only Order 1 would meet the criteria
(because order 2 contained something not in the list). If the target list
was [Apple, Orange, Banana], both orders would match. If the target list
was [Banana], either of the orders would match.
I'm not opposed to creating a view and selecting from that.
Off to dowse the flames coming from my ears,
Bob M..