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)
Member Avatar for Geek-Master

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.