query with multiple criteria

odun

Registered User.
Local time
Yesterday, 17:56
Joined
Apr 24, 2005
Messages
108
Hello all:

I need your help with the following.

I have a table in access, the fields I would like to filter on are:
Sales org
Profit center
Account
Customer

I would like to do the following in this sequence:

1) Filter for Sales org= 6101
then
2) provide all profit center after filter (1) EXCEPT for profit center = 6101SALM01
then
3) provide all profit center after filter (2) EXCEPT for profit center starting with 6101D*
then
4) ignore all accounts starting with 7* except if Bill Customer Name includes *C*

I tried putting this together, but I am not getting the right results.

Please help,
Odun
 
SELECT [Sales org], [Profit center], [Account], [Customer]
FROM [TableName]
WHERE [Sales org]="6101" AND ([Profit center]<>"6101SALM01" And [Profit center] Not Like "6101D*") AND ([Account] Not Like "7*" Or [Customer] Like "*C*")=True;


If [Sales org] is a numeric field, remove the double-quotes surrounding the value 6101.
.
 
Thanks a lot Jon, that worked!

If I were to change this sql for the following:

1) Filter for Sales org = 61H0
then
2) Filter for profit center starting with 61H* except for profit center = 61HKS56800
then
3) all accounts except those starting with 7*

Would this be correct:

SELECT [Sales org], [Profit center], [Account], [Customer]
FROM [TableName]
WHERE [Sales org]="61H0" AND ([Profit center] Like "61H*" AND ([Profit center]<>"61HKS56800" ) AND ([Account] Not Like "7*");

Thanks again
 

Users who are viewing this thread

Back
Top Bottom