Here comes a quick way to list all the months and their corresponding numbers using Oracle’s connect by level.
Select level month_number, to_char(add_months(trunc(sysdate,'YEAR'), level-1),'Month') month_name from dual connect by level < 13;
As the level starts with 0, there is no need to sort the values once again & this query could be used with Oracle forms LOVs.
2 thoughts on “Oracle SQL | Get Month Names & numbers using connect by level”
how to mention year on each month name
You mean like May-2022? Or additional year column?