Reputation: 125
I have a list of month in database. In query output I would like to Order by month But in very specific order. ('DEC', 'JUL', 'MAR', 'OCT,' 'MAY', 'JUN', 'FEB', 'AUG', 'SEP', 'APR', 'NOV', 'JAN') Something like:
Select month from month_table
Order by month
How to specify customized Order?
Upvotes: 0
Views: 158
Reputation: 1271161
In MySQL, you can use the field()
function:
order by field(month, 'DEC', 'JUL', 'MAR', 'OCT,' 'MAY', 'JUN', 'FEB', 'AUG', 'SEP', 'APR', 'NOV', 'JAN')
Upvotes: 1