Below is the query to find monthly average of number of records created. CREATED DATE IS TIMESTAMP
select year,month, (ymcount/maxmonthdays) as monthaverage ymcount from (
select year,month,maxmonthdays, count(1) ymcount from (
SELECT year(created) as year, MONTHNAME(created) as month,
day(date(date(created))-(day(date(created)) -1) days + 1 month -1 day) as maxmonthdays
FROM tablename )
group by year,month,maxmonthdays );
NOTE: To find max number of days in a month, I have used below command.
day(date(date(created))-(day(date(created)) -1) days + 1 month -1 day) as maxmonthdays
One can use last_day function supported after DB2 version 9.7 onwards, I m using version 9.5.