Skip to Main Content

SQL Developer

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Grouping, Sorting, And Counting

User_MMW9KOct 27 2021

If you have a list of dates, how do you group by month, and then count the frequency of entries per month for each month?

Comments

KayK

Hi MMW,
welcome to the communities.
Do you look for something like this ?

< scott:op57@unxsy078 > select count(*), to_char(HIREDATE, 'yyyymm')
 2   from emp t
 3  group by to_char(HIREDATE, 'yyyymm')
 4  order by 2;

   COUNT(*) TO_CHA
------------ ------
          1 198012
          2 198102
          1 198104
          1 198105
          1 198106
          2 198109
          1 198111
          2 198112
          1 198201
          1 198704
          1 198705

regards
Kay
btw please choose a more readable name for your avatar. You're more than a number. Have a look at this: Update Your Community Display Name and Avatar!

IswaryaR

SELECT TO_CHAR(HIRE_DATE,'MON') HIRE_MONTH ,COUNT(*) CNT
FROM EMP
GROUP BY TO_CHAR(HIRE_DATE,'MON')
ORDER BY HIRE_MONTH

EdStevens

BTW, this question has nothing to do with the subject of this forum, which is SQL Developer. The question is purely a SQL question, so belongs in the SQL & PL/SQL space.

1 - 3

Post Details

Added on Oct 27 2021
3 comments
108 views