Good Day Experts!
I am not sure if what I am wanting to do is even "allowed" . So I don't spend more time looking, hopefully you can help. I am currently working on converting several queries to use passed in parameters in place of hard-coded values. Some new functionality is also being added.
I have an aliased select/sum query in the select list of a query. I could not figure out how to use that alias to condition on in the WHERE portion of the query. I ended up wrapping the entire Query in a Select so I could "see" and reference the aliased field in the where clause of that outer query, I am trying to, based on an incoming parameter value, create a different Where clause.
If the passed in parameter value is a 0, I would need to not create the Where clause. If the parameter value is not zero and not negative then I would want
to create a Where clause. Since I could not figure out how to do it, I ended up conditioning on the parameter and using the query 2 times in an If/Else.
Do you have any ideas? Is it even possible to conditionally create a Where clause?