Solved

Using CASE in WHERE Clause

Posted on 2010-11-09
3
250 Views
Last Modified: 2012-05-10
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
Comment
Question by:WaldaInc
  • 2
3 Comments
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 34097308
AND (
(typeid=1 OR Isnull(m.member,'FALSE')='TRUE') -- one of
OR
-- rest of clause
0
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 500 total points
ID: 34097310
AND (
(typeid=1 OR Isnull(m.member,'FALSE')='TRUE') -- one of
OR
-- rest of clause
0
 

Author Closing Comment

by:WaldaInc
ID: 34207903
Thanks.

Worked fine once implemented.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now