I have a table which has a field Month_Name and it contains the names of the month. I want to ORDER BY the month names, not alphabetically, but by its actual order, like, January, February, etc. How can I implement this using PostgreSQL?
Is there any way that I can convert the Month Name 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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With