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

Using CASE in WHERE Clause

Hello I have the following code in my WHERE clause

AND
(
     ISNULL(m.Member,'FALSE') = 'TRUE'
     OR
     (
          ISNULL(vc.Amount,0) != 0
          AND vc.VoluntaryContributionTypeID = @contribtuionTypeID
     )
)

This works really well. However I've now been giving some additional requirements and I'm ot sure how to make the SQL work.

If a varialbe called TypeID (not shown in above code) is = 1, then I don't want the clause to evaluate this portion:

ISNULL(m.Member,'FALSE') = 'TRUE'

So if TypeID is 1, I don't care about the n.Member field, if it is not 1, I do care.

Any easy way to write that statement?
0
WaldaInc
Asked:
WaldaInc
  • 2
1 Solution
 
cyberkiwiCommented:
AND (
(typeid=1 OR Isnull(m.member,'FALSE')='TRUE') -- one of
OR
-- rest of clause
0
 
cyberkiwiCommented:
AND (
(typeid=1 OR Isnull(m.member,'FALSE')='TRUE') -- one of
OR
-- rest of clause
0
 
WaldaIncAuthor Commented:
Thanks.

Worked fine once implemented.
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

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

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