Confusing title, I know. I haven't found this particular question asked/answered anywhere. I'd appreciate some help.
Depending on the state of a checkbox that says "Include Inactives," I want to select a group of customers based on their statuses. (The table has rows with statuses of A, I, C, H, and X.)
The select statement was originally written like this:
Select custNum, custName from Customer where custStatus in (case when @chkboxValue=0 then 'A' else 'I,A' end)
I don't see how, but if the Include Inactives checkbox is unchecked, it actually works, returning all customers with status of A. But if the checkbox is unchecked, I get nothing, which is what I expected because of the incorrect syntax that results
from the else.
I've tried putting in lots of combinations of double apostrophes. I think this ought to work, but it doesn't:
Select custNum, custName from Customer where custStatus in (case when @chkboxValue=0 then ''A'' else ''I','A'' end)
In fact, that way, it doesn't return anything, regardless of checkbox state.
Thanks for any ideas.
View Complete Post