Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to arrange the data according to financial year month ....and my financial years goes like this april,may ,june ,july and so on ......i want the order in this way
Posted

Use this:

SQL
SELECT --whatever
...
...
ORDER BY DECODE(month, 'April', 0, 'May', 1, 'June', 2, 'July', 3, 'August', 4, 'September', 5, 'October', 6, 'November', 7, 'December', 8, 'January', 9, 'February', 10, 'March', 11, 12)


If the month is stored as an integer (e.g. Jan=1, Feb=2,...):

SQL
SELECT --whatever
...
...
ORDER BY ((month + 9) % 12)
 
Share this answer
 
v2
SQL
BEGIN
select distinct(datename(month,date))  as AccountName,(CASE WHEN DATEPART(MM,date)=4 THEN 1
WHEN DATEPART(MM,date)=5 THEN 2
WHEN DATEPART(MM,date)=6 THEN 3
WHEN DATEPART(MM,date)=7 THEN 4
WHEN DATEPART(MM,date)=8 THEN 5
WHEN DATEPART(MM,date)=9 THEN 6
WHEN DATEPART(MM,date)=10 THEN 7
WHEN DATEPART(MM,date)=11 THEN 8
WHEN DATEPART(MM,date)=12 THEN 9
WHEN DATEPART(MM,date)=1 THEN 10
WHEN DATEPART(MM,date)=2 THEN 11
WHEN DATEPART(MM,date)=3 THEN 12

END )
as date from tableabc order by mn
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900