Dynamic Conditional Where Clause in SQL
SELECT < col1 > , < col2 >
FROM < table >
WHERE col1 like DECODE(:Param_one,'ALL','%',:Param_one) or
NVL(col2,'#') = case
when :Param_one = 'ALL' then
'#'
else
col2
end
SELECT < col1 > , < col2 >
FROM < table >
WHERE col1 like DECODE(:Param_one,'ALL','%',:Param_one) or
NVL(col2,'#') = case
when :Param_one = 'ALL' then
'#'
else
col2
end