Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering Data in a Query with or/and ? 1

Status
Not open for further replies.

sgp_imported

Technical User
Sep 11, 2001
8
0
0
US
The following query works fine until I try to add another criteria to filter out: not like "S*" or not like "L*" (When I do it ignores both criteria)
------------------------------------------------------------
SELECT
[T1 Net Data].INVOICE_NUMBER,
Min([T1 Net Data].CUSTOMER_NUMBER) AS MinOfCUSTOMER_NUMBER,
Min([T1 Net Data].CUSTOMER_NAME) AS MinOfCUSTOMER_NAME,
Min([T1 Net Data].Salesman_Number) AS MinOfSalesman_Number,
Max([T1 Net Data].Datevalue2) AS MaxOfDatevalue2,
Min([T1 Net Data].Datevalue1) AS MinOfDatevalue1,
Min(OAUSER_SALESMAN.CLASS_CODE) AS MinOfCLASS_CODE

FROM [T1 Net Data] LEFT JOIN OAUSER_SALESMAN ON [T1 Net Data].Salesman_Number = OAUSER_SALESMAN.SALESMAN_NUMBER

GROUP BY [T1 Net Data].INVOICE_NUMBER

HAVING

(((Min([T1 Net Data].CUSTOMER_NUMBER))not Like "S*")

AND

((Max([T1 Net Data].Datevalue2))>=#1/1/2002# And (Max([T1 Net Data].Datevalue2))<#1/1/2003#));
------------------------------------------------------------
My problem is when I try to add another criteria to filter out: not like &quot;S*&quot; or not like &quot;L*&quot; (When I do it ignores both criteria)

Thanks!
 
L1000 is not like S* so that row is accepted;
S1000 is not like L* so that row is accepted.
Combining these conditions with OR pretty much guarantees that every row will be accepted.

If you want to exclude the L*'s and the S*'s then combine the conditions with AND.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top