Sub Query selection based on parameter value selected
843762Mar 8 2011 — edited Mar 8 2011I have a parameter, and based on the value selected, I want to run one of two queries. I thought I could do either an IF THEN ELSE, or a CASE, but neither seem to be working.
What I'm trying to do is this:
IF parameter_value = 338 THEN
(RUN THIS SELECT QUERY)
ELSE
(RUN THIS SELECT QUERY)
END IF
or
SELECT CASE WHEN parameter_value = 338 THEN (RUN THIS SELECT QUERY)
ELSE (RUN THIS SELECT QUERY)
END X
I'm getting errors with both. For the CASE statement, it says "too many values". For the IF statement, it just says "invalid SQL statement".
Any suggestions would be appreciated.
Thanks.