Table tblDistResell (the first row is the column headers):
- DISTRIBUTOR RESELLER STATE
- ABC BestBuy CA
- ABC RadioShack NJ
- XYZ BestBuy CA
- XYZ RadioShack MO
Query:
SELECT Distributor
WHERE
(
(Reseller = 'BestBuy' AND [State]='CA') OR (Reseller = 'RadioShack' AND [State]='NJ')
);
Resultset:
- DISTRIBUTOR RESELLER STATE
- ABC BestBuy CA
- ABC RadioShack NJ
- XYZ BestBuy CA
When EVERY row for a distributor is returned, we want the count (or the resultset; whatever's easier).
But if only ONE (or more) distributor record(s) aren't returned, we want to ignore all of that distributor's results.
In other words, given the example above, we want to see either,
- DISTRIBUTOR RESELLER STATE
- ABC BestBuy CA
- ABC RadioShack NJ
or
count == 2
(No XYZ records, since the RadioShack, MO record is missing from the resultset.)
Here's one more example for clarity...
Let's use the same table, tbltblDistResell, but a modified query:
SELECT Distributor
WHERE
(
(Reseller = 'BestBuy' AND [State]='MO') OR (Reseller = 'RadioShack' AND [State]='NJ')
);
In this case, the following is returned:
- DISTRIBUTOR RESELLER STATE
- ABC RadioShack NJ
But since there is some ABC data that wasn't returned, we want to see either:
- (0 row(s) affected)
or
count == 0
The challenge is that the tool we're using only allows us to modify the WHERE clause!
Any help would be greatly appreciated.
Greg
Aucun commentaire:
Enregistrer un commentaire