How to use order by stop ordering the names of the months in Oracle

2

Hello, I'd like to know how to solve this problem. I would take the name of the days of the month and order them and not the numbers of the corresponding months. It follows the query that I performed but that only orders in numbers corresponding to the months.

SELECT to_char(hsp_checkin, 'month') as "Mês", 
       count(hsp_id) as "Total de Hospedagens" 
FROM HOSPEDAGENS
GROUP BY to_char(hsp_checkin, 'month');

Minor correction in the question description. "I would like to take the name of the days of the month" is actually: I would like to get the name of the months.

    
asked by anonymous 05.12.2018 / 20:44

1 answer

1

As commented in the question, you should add the order by :

SELECT to_char(hsp_checkin, 'month') as "Mês", 
   count(hsp_id) as "Total de Hospedagens" 
FROM HOSPEDAGENS
GROUP BY to_char(hsp_checkin, 'month')
ORDER BY 1; -- to_char(hsp_checkin, 'month')
    
06.12.2018 / 11:54