Site icon Duh! Microsoft did it again

Oracle SQL | Get Month Names & numbers using connect by level

Advertisements

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.

Exit mobile version