Order using month name in PostgreSQL

I have a table that has a Month_Name field and contains the names of the month. I want to ORDER the names of the months, not in alphabetical order, but in their actual order, like January, February, etc. How can I implement this with PostgreSQL?

Is there any way to convert the name of the month to its numeric value?

id        billed_unit    billed_amount    town_id    ea_month    ea_year    
3959920   3695.17        25856.84         CHRY     April         2014
3959920   3695.17        25856.84         CHRY     August        2014
3959920   3695.17        25856.84         CHRY     February      2014
3959920   3695.17        25856.84         CHRY     July          2014
3959920   3695.17        25856.84         CHRY     June          2014
3959920   3695.17        25856.84         CHRY     March         2014

      

+3


source to share


1 answer


SELECT * 
FROM EA.TOWN_CONS_BILLING_ROLLUP 
WHERE TOWN_ID='CHRY' 
      AND EA_YEAR=2014 
ORDER BY   
to_date(ea_month,'Month');

      



Data type formatting functions

+5


source







All Articles