• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 139
  • Last Modified:

Where clause in query

I have a query need the following 3 criteria: the Finished must be "No". Of the ones with a Finished = No, two things can happen... either there is a value entered in CallBackDate OR WorthCallBack is Yes.

Finished = No (everyone must have this)
With the ones that have Finished = No then: CallBackDate = [a value entered] OR WorthCallBack = Yes

Thanks!
0
cansevin
Asked:
cansevin
  • 5
  • 4
1 Solution
 
omgangIT ManagerCommented:
WHERE (((Finished)="No") AND (Not (CallBackDate) Is Null)) OR (((Finished)="No") AND ((WorthCallBack)="Yes"));

OM Gang
0
 
cansevinAuthor Commented:
Thanks OM, it currently is saying there is a Syntax Error (mission operation) in the query expression

Then lists the Where and the Group By

I also need one more parameter... only for data with DateCalled between 1/1/2015 and 12/31/2015.

Thanks for your help.
0
 
omgangIT ManagerCommented:
Please post up the current SQL statement.
OM Gang
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
cansevinAuthor Commented:
SELECT [Memo List Table].MemoNumber, [Memo List Table].DateCalled, [Memo List Table].MemoEmail, [Memo List Table].TypeOfClient, [Memo List Table].NewClientType, [Memo List Table].CallBackDate, [Memo List Table].Memo, ReachOutSales.MemoNum
FROM [Memo List Table] INNER JOIN ReachOutSales ON [Memo List Table].MemoNumber = ReachOutSales.MemoNum
WHERE (((Finished)="No") AND ((Not (CallBackDate)Is Null)) OR (((Finished)="No") AND ((WorthCallBack)="Yes"))
GROUP BY [Memo List Table].MemoNumber, [Memo List Table].DateCalled, [Memo List Table].MemoEmail, [Memo List Table].TypeOfClient, [Memo List Table].NewClientType, [Memo List Table].CallBackDate, [Memo List Table].Memo, ReachOutSales.MemoNum;

Open in new window

0
 
omgangIT ManagerCommented:
I had one too many left parentheses in the WHERE clause.  Try this

SELECT [Memo List Table].MemoNumber, [Memo List Table].DateCalled, [Memo List Table].MemoEmail, [Memo List Table].TypeOfClient, [Memo List Table].NewClientType, [Memo List Table].CallBackDate, [Memo List Table].Memo, ReachOutSales.MemoNum
FROM [Memo List Table] INNER JOIN ReachOutSales ON [Memo List Table].MemoNumber = ReachOutSales.MemoNum
WHERE (((Finished)="No") AND (Not (CallBackDate)Is Null) AND ((DateCalled) Between #1/1/2015# And #12/31/2015#)) OR (((Finished)="No") AND ((DateCalled) Between #1/1/2015# And #12/31/2015#) AND ((WorthCallBack)="Yes"))
GROUP BY [Memo List Table].MemoNumber, [Memo List Table].DateCalled, [Memo List Table].MemoEmail, [Memo List Table].TypeOfClient, [Memo List Table].NewClientType, [Memo List Table].CallBackDate, [Memo List Table].Memo, ReachOutSales.MemoNum;

Open in new window

0
 
cansevinAuthor Commented:
Ok... now it says "DataType mismatch" I'll open another question... that usually is different issue. Thanks!
0
 
omgangIT ManagerCommented:
Data Type mismatch.  Is the Finished Field Boolean (Yes/No)?  Or the WorthCall field, is it Boolean (Yes/No)?  In your Q, you had wrapped "No" in quotes so I proceeded as if it was a text field.  If it's a Boolean field then you simply changed the WHERE clause like this

SELECT [Memo List Table].MemoNumber, [Memo List Table].DateCalled, [Memo List Table].MemoEmail, [Memo List Table].TypeOfClient, [Memo List Table].NewClientType, [Memo List Table].CallBackDate, [Memo List Table].Memo, ReachOutSales.MemoNum
FROM [Memo List Table] INNER JOIN ReachOutSales ON [Memo List Table].MemoNumber = ReachOutSales.MemoNum
WHERE (((Finished)=False) AND (Not (CallBackDate)Is Null) AND ((DateCalled) Between #1/1/2015# And #12/31/2015#)) OR (((Finished)=False) AND ((DateCalled) Between #1/1/2015# And #12/31/2015#) AND ((WorthCallBack)=True))
GROUP BY [Memo List Table].MemoNumber, [Memo List Table].DateCalled, [Memo List Table].MemoEmail, [Memo List Table].TypeOfClient, [Memo List Table].NewClientType, [Memo List Table].CallBackDate, [Memo List Table].Memo, ReachOutSales.MemoNum;

Open in new window

0
 
cansevinAuthor Commented:
Genius... thanks. If you want, post that answer to my new questions. I already closed this one before it was submitted. I appreciate your help on this!
0
 
omgangIT ManagerCommented:
You can close that Q; I feel it was all part of the same solution on my part.  Thanks though.
OM Gang
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now