Skip to Main Content

Oracle Database Discussions

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!

Oracle DBA - Group by Date as Month

SANPATAug 6 2022

Dear Friends
I need to run the query where i need to group the data based on Month and year from the entry_date. Entry date is stored as DD-MM-YYYY HH24:MM:SS in date format.
Query as :
select to_char(entry_date,'MM YYYY),sum(qty)qty FROM TABLE GROUP BY TO_CHAR(ENTRY_DATE,'MM YYYY),QTY
it shows all the records. we need a result all the records should get group for the particular month and sum qty .
Kindly suggest.
Sanjay

This post has been answered by Solomon Yakobson on Aug 6 2022
Jump to Answer

Comments

Solomon Yakobson
Answer
select  to_char(trunc(entry_date,'MM'),'MM YYYY),
        sum(qty) qty
  from  your_table_name
  group by trunc(entry_date,'MM')
  order by trunc(entry_date,'MM')
/

SY.

Marked as Answer by SANPAT · Aug 9 2022
1 - 1

Post Details

Added on Aug 6 2022
1 comment
600 views