WITH years AS ( SELECT ADD_MONTHS (TO_DATE ('01-01-2020', 'DD-MM-YYYY'), LEVEL * 12) year FROM DUAL CONNECT BY LEVEL <= 30) SELECT TO_CHAR (year, 'YYYY') year FROM years WHERE year < TO_DATE ('01-01-' || TO_CHAR (SYSDATE, 'YYYY'), 'DD-MM-YYYY') ORDER BY 1 DESC;
Script Output
Year
Year
2023
2022
2021