Hi,
I am wondering if this is possible:
SELECT TOP 20 *,
CASE @Mode = 'Equity' THEN
Code IN ('ABC', 'CDE')
CASE @Mode = 'NonEquity' THEN
Code NOT IN ('ABC', 'CDE')
FROM #myTable
ORDER BY ABS(Ratio*100-100) DESC
Error:
Incorrect syntax near the keyword 'IN'.
Basically, I need the "WHERE clause" to change depending on the variable value. But I'm not sure where to stick the WHERE clause.
Most of the examples online are too simplistic.
Thanks
I am wondering if this is possible:
SELECT TOP 20 *,
CASE @Mode = 'Equity' THEN
Code IN ('ABC', 'CDE')
CASE @Mode = 'NonEquity' THEN
Code NOT IN ('ABC', 'CDE')
FROM #myTable
ORDER BY ABS(Ratio*100-100) DESC
Error:
Incorrect syntax near the keyword 'IN'.
Basically, I need the "WHERE clause" to change depending on the variable value. But I'm not sure where to stick the WHERE clause.
Most of the examples online are too simplistic.
Thanks