I’m currently making a stored procedure which offers the user a filter system to drill down. Now I’m stumped at trying to put in a conditional clause in the where statement. As seen below:
WHERE upper(stk.warehouse) LIKE '%' + upper(@warehouse) + '%' AND
upper(stk.product) LIKE '%' + upper(@product) + '%' AND
upper(stk.description) LIKE '%' + upper(@description) + '%' AND
upper(stk.long_description) LIKE '%' + upper(@longdescription) + '%' AND
cast(safety_stock_level as decimal(20)) LIKE '%' +
upper(@barcode) + '%' AND
(stk.physical_qty + stk.on_order_qty -stk.allocated_qty - stk.back_order_qty -
stk.uninspected_qty)>@available AND
*if @or =0 BEGIN
stk.on_order_qty > @onorder AND stk.physical_qty > @phys
else
stk.on_order_qty > @onorder OR stk.physical_qty > @phys*
Now I’ve tried an if statement to no prevail and also a case statement. Is having a conditional OR or AND statement even possible?
You would do it like this: