Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Issue in sorting by month

NessJun 23 2021 — edited Jun 23 2021

Hi all,

I have a column naming Period which is of varchar2(15) datatype.
Under this column it has data like months:
Period (column name)
Apr-2021
Aug-2021
May-2021
So ,i want to sort the data in financial year format i.e say Apr-2021-Mar-2022 so april . So April should come first and march last.
I tried with this queries:
1)select period from invoice_header order by to_char(period,'Mon-YYYY')----got error not a valid month.
2)select period from invoice_header order by decode(substr(period,1,3),'Apr',1,'May',2,'Jun',3,'Jul',4,'Aug',5,'Sep',6,'Oct',7,'Nov',8,'Dec',9,'Jan',10,'Feb',11,'Mar',12) Asc-------did not sort month

Plzzzz Help.
Thanks in advance!

Comments
Post Details
Added on Jun 23 2021
11 comments
566 views