Even if possible, this is not a good idea. Functions in a line can ruin performance.
In this case, the best way is probably just combining two exclusive queries:
SELECT discount_amount FROM vw_ph_discount_data WHERE sysdate > start_date AND end_date IS NULL UNION ALL SELECT discount_amount FROM vw_ph_discount_data WHERE sysdate > start_date AND end_date IS NOT NULL AND sysdate < end_date
(changed to NULL from EMPTY , as this seems to be what you were).
Assuming end_date indexed, this should scream, even if it's two queries. The need for additional processing on each returned line is rarely a good idea.
Whatever methods you choose to research, compare them with real-world data. The main optimization directive is a measure, donβt guess.
source share