Вы можете использовать комбинацию функций to_date (), to_char () и оператора case.Примерно так:
SELECT CASE when schedule IS NULL THEN to_char(SYSDATE, 'MONTH')
when (to_date(schedule, 'MM/DD/YYYY') < SYSDATE) THEN to_char(SYSDATE, 'MONTH')
else to_char(to_date(schedule, 'MM/DD/YYYY'), 'MONTH')
END AS SCHEDULE
FROM my_table;
Тест:
CREATE TABLE MY_TABLE (SCHEDULE VARCHAR(10));
INSERT INTO MY_TABLE (SCHEDULE) VALUES ('3/22/2017');
INSERT INTO MY_TABLE (SCHEDULE) VALUES ('4/28/2017');
INSERT INTO MY_TABLE (SCHEDULE) VALUES ('5/3/2017');
INSERT INTO MY_TABLE (SCHEDULE) VALUES (NULL); -- test for null record
INSERT INTO MY_TABLE (SCHEDULE) VALUES ('6/1/2019'); -- test for future record (current May 2019)
COMMIT;
SELECT SCHEDULE as ORIGINAL_VALUE, CASE
when schedule IS NULL THEN to_char(SYSDATE, 'MONTH')
when (to_date(schedule, 'MM/DD/YYYY') < SYSDATE) THEN to_char(SYSDATE, 'MONTH')
else to_char(to_date(schedule, 'MM/DD/YYYY'), 'MONTH')
END as SCHEDULE_OUTPUT
FROM my_table;
DROP TABLE MY_TABLE;
Результаты:
ORIGINAL_VALUE SCHEDULE_OUTPUT
3/22/2017 MAY
4/28/2017 MAY
5/3/2017 MAY
MAY
6/1/2019 JUNE