[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Using CASE in WHERE Clause

Posted on 2010-11-09
3
Medium Priority
?
266 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

656 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