0

Hey everyone I want a where clause based off a variable input and I'm having some trouble with the syntax. My current code(incorrect) is below but it shows what I am aiming for. Does anyone have any suggestions?

(CASE
    WHEN @inIndustry = 'ALL' THEN 
        WHERE EXISTS (SELECT 1 FROM sysdba.C_PROJECTREVENUE 
               WHERE OpportunityID = op.OpportunituID AND monthyear LIKE '%' + @Year1)
    ELSE
        WHERE (acIF.Industry <> 'Defense' OR acIF.Industry IS NULL) 
            AND EXISTS (SELECT 1 FROM sysdba.C_PROJECTREVENUE 
                   WHERE OpportunityID = op.OpportunituID AND monthyear LIKE '%' + @Year1) END)
2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by Geek-Master
0

For starters, I did notice that your right hand column is spelt different. Should it be op.OpportunityID?
Your Code

WHERE OpportunityID = op.OpportunituID

Possible Correction

WHERE OpportunityID = op.OpportunityID

Can you post the actual Syntax error message you are recieving? That would greatly help diagnose the problem.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.