Conditional WHERE clause based on parameter input
When restricting data based on a parameter I usually use the following:
AND p.start_date = NVL (p_start_date, p.start_date)
so IF the parameter is null THEN I just join on itself, ELSE we filter on parameter.
New requirement involves greater than or equal to, so I tried this:
AND CASE
WHEN (p_start_date = NULL) THEN
p.start_date = p.start_date
ELSE
p.start_date >= p_start_date
END;
but this is, at a minimum, is syntactically wrong.
Any suggestions?
Thanks!