WaldaInc
asked on
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.VoluntaryContributionTy peID = @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?
AND
(
ISNULL(m.Member,'FALSE') = 'TRUE'
OR
(
ISNULL(vc.Amount,0) != 0
AND vc.VoluntaryContributionTy
)
)
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks.
Worked fine once implemented.
Worked fine once implemented.
(typeid=1 OR Isnull(m.member,'FALSE')='
OR
-- rest of clause