我想修改下面给出的现有 SQL 查询(编号 1)。首先,我需要知道是否可以做我想做的事情(第 2 点)。如果是,那么我可以通过哪些方式做到这一点。
--**(Number 1)** What I currently have
SELECT Column1
FROM dbo.Table1
WHERE ColumnValue1 = 'One'
AND scalarFunctionResult(Var) = 'Word1'
AND ColumnValue2 = "Word2"
--*(Number 2)* What I need
SELECT Column1
FROM dbo.Table1
WHERE ColumnValue1 = 'One'
AND SomeVariable IN (scalarFunctionResult(Var) = 'Word1', 'WordA')
-- Perform a query based
--on value of SomeVariable, Please read pseudo code below
AND ColumnValue2 = "Word2"
--Pseudo code for logic
--if(SomeVariable = 'Word1') then run query ABCD,
--else if(SomeVariable = 'WordA') then run some other query EFGH