Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where Case expression or Boolean

Status
Not open for further replies.

dianemarie

Instructor
Jul 11, 2001
583
US
Hello,

In English, I need to say this in my Where statement:

If @Division = M then oh.division in ('Management','In-House')
If @Division = B then oh.division in ('Brokerage','In-House')
else oh.listdiv <> 'C' (@Division = A)

I've been trying it using Case, and also Boolean. I'm having no success getting it to work. Any help would be appreciated. This was my last try:

where

(case @Division
when 'M' then
case oh.division
when 'Management' then 1
when 'In-House' then 1
else 0
end
when 'B' then
case oh.division
when 'Brokerage' then 1
when 'In-House' then 1
else 0
end
when 'A' then
case oh.listdiv
when 'c' then 0
else 1
end) = 1


 
How about?
Code:
CASE
   WHEN @Division = 'M' AND oh.division IN ('In-House','Management') THEN 1
   WHEN @Division = 'B' AND oh.division IN ('In-House','Brokerage') THEN 1
   WHEN @Division = 'A' AND oh.listdiv <> 'C' THEN 1
   ELSE 0
END = 1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top