How can I make an annual report, grouped by month?

I use the following query to list the number of transactions by month. Does anyone know how I can list a year. This means that the request returns all my transactions for the whole year, except for the current month.

That is, if today is August 29, 2011, I need an annual report, grouped by months until July (from August not completed)

select to_char(date,'MONTH YYYY'), sum(number_of_transactions) from header group by date order by date 
+4
source share
2 answers
 select to_char(trunc(date,'yyyy'),'YYYY') as year, sum(number_of_transactions) from header where date < trunc(sysdate, 'mm') group by trunc(date,'yyyy') order by year 
+5
source

That's what you need?

 SELECT TO_CHAR(date, 'YYYY'), SUM(number_of_transactions) FROM header GROUP BY TO_CHAR(date, 'YYYY') 
0
source

Source: https://habr.com/ru/post/1369465/


All Articles