Is it possible in Oracle to put conditional IF statements in the WHERE clause?
I want to filter all rows with an end date before today. And if the end date is empty, it should not filter on it. I've tried this:
SELECT discount_amount
FROM vw_ph_discount_data
WHERE sysdate > start_date
AND
IF
end_date IS NOT EMPTY
THEN
sysdate < end_date
But I get "invalid relational operator".
You can try:
SELECT discount_amount
FROM vw_ph_discount_data
WHERE sysdate > start_date
AND sysdate < nvl(end_date,sysdate+1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With