Find the average of ids in a month
问题 I can calculate the number of ids in a month and then sum it up over 12 months. I also get the average using this code. select id, to_char(event_month, 'yyyy') event_year, sum(cnt) overall_count, avg(cnt) average_count from ( select id, trunc(event_date, 'month') event_month, count(*) cnt from daily where event_date >= date '2019-01-01' and event_date < '2019-01-31' group by id, trunc(event_date, 'month') ) t group by id, to_char(event_month, 'yyyy') The results looks something like this: ID|