Created
February 14, 2017 15:10
-
-
Save ramiroaznar/ca302e03fcbc6af70b64115e9fb63bd2 to your computer and use it in GitHub Desktop.
How to convert month number to month strings with PostgreSQL conditionals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT *, | |
CASE WHEN month = 1 THEN 'January' | |
WHEN month = 1 THEN 'January' | |
WHEN month = 2 THEN 'February' | |
WHEN month = 3 THEN 'March' | |
WHEN month = 4 THEN 'April' | |
WHEN month = 5 THEN 'May' | |
WHEN month = 6 THEN 'June' | |
WHEN month = 7 THEN 'July' | |
WHEN month = 8 THEN 'August' | |
WHEN month = 9 THEN 'September' | |
WHEN month = 10 THEN 'October' | |
WHEN month = 11 THEN 'November' | |
ELSE 'December' END as month_string | |
FROM table_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment