The forum database structure could not be simpler, it mirrors precisely the CVS files which are generated every month.
SELECT
`forum_posts`.`month` as month,
`forum_posts`.`year` as year,
date_format(date_add( makedate(year, 1), interval month-1 MONTH), '%b %Y') as monthstr,
concat(cast(year as char), LPAD(cast(month as char), 2, '0')) as monthnum,
`forum_posts`.`forum` as forum,
`forum_posts`.`posts` as posts
FROM
`forum_posts`
ORDER BY
`forum_posts`.`forum` ASC,
`forum_posts`.`year` ASC,
`forum_posts`.`month` ASC
SELECT
`forum_top_posters`.`month`,
`forum_top_posters`.`year`,
`forum_top_posters`.`rank`,
`forum_top_posters`.`member`,
`forum_top_posters`.`posts`,
monthname(${last_month}) AS monthname
FROM
`forum_top_posters`
WHERE
month = month(${last_month})
AND year = year(${last_month})
limit 20
SELECT
month,
year,
rank,
title,
views
FROM
`forum_most_viewed_threads`
WHERE
month=MONTH(${last_month})
AND
year=YEAR(${last_month})
ORDER BY
views ASC
SELECT
`forum_cumulative_posts`.`month`,
`forum_cumulative_posts`.`year`,
`forum_cumulative_posts`.`forum`,
`forum_cumulative_posts`.`posts`
FROM
`forum_cumulative_posts`
ORDER BY
`forum_cumulative_posts`.`forum`,
`forum_cumulative_posts`.`year` ASC,
`forum_cumulative_posts`.`month`
SELECT
`forum_top_thanked`.`month`,
`forum_top_thanked`.`year`,
`forum_top_thanked`.`rank`,
`forum_top_thanked`.`member`,
`forum_top_thanked`.`thanks`
FROM
`forum_top_thanked`
WHERE
month = month(${last_month})
AND year = year(${last_month})
order by rank
limit 20
SELECT
`forum_cumulative_threads`.`month`,
`forum_cumulative_threads`.`year`,
date_format(date_add( makedate(year, 1), interval month-1 MONTH), '%b %Y') as monthstr,
concat(cast(year as char), LPAD(cast(month as char), 2, '0')) as monthnum,
`forum_cumulative_threads`.`forum`,
`forum_cumulative_threads`.`threads`
FROM
`forum_cumulative_threads`
ORDER BY
`forum_cumulative_threads`.`forum` ASC,
`forum_cumulative_threads`.`year` ASC,
`forum_cumulative_threads`.`month` ASC
SELECT
`forum_top_posters`.`month`,
`forum_top_posters`.`year`,
`forum_top_posters`.`rank`,
`forum_top_posters`.`member`,
`forum_top_posters`.`posts`,
monthname(${last_month}) AS monthname
FROM
`forum_top_posters`
WHERE
month = month(${last_month})
AND year = year(${last_month})
limit 10
SELECT
`forum_posts`.`month` as month,
`forum_posts`.`year` as year,
date_format(date_add( makedate(year, 1), interval month-1 MONTH), '%b %Y') as monthstr,
concat(cast(year as char), LPAD(cast(month as char), 2, '0')) as monthnum,
`forum_posts`.`forum` as forum,
`forum_posts`.`posts` as posts
FROM
`forum_posts`
where
month>=MONTH(DATE_SUB(NOW(), INTERVAL 4 MONTH)) and
year>=YEAR(DATE_SUB(NOW(), INTERVAL 4 MONTH))
ORDER BY
`forum_posts`.`forum` ASC,
monthnum ASC
SELECT
count(`forum_top_posters`.`member`) as active_count,
monthname(${last_month}) AS monthname
FROM
`forum_top_posters`
WHERE
month = month(${last_month})
AND year = year(${last_month})
AND `forum_top_posters`.`posts`>=2
SELECT
count(`forum_top_posters`.`member`) as poster_count,
monthname(${last_month}) AS monthname
FROM
`forum_top_posters`
WHERE
month = month(${last_month})
AND year = year(${last_month})
select
sum(posts) as total_posts
FROM
forum_posts
WHERE
forum_posts.month = MONTH(${last_month})
AND
forum_posts.year = YEAR(${last_month})
SELECT
`forum_hottest_threads`.`month`,
`forum_hottest_threads`.`year`,
`forum_hottest_threads`.`rank`,
`forum_hottest_threads`.`title`,
`forum_hottest_threads`.`posts`
FROM
`forum_hottest_threads`
WHERE
`forum_hottest_threads`.`month`=month(${last_month})
AND
`forum_hottest_threads`.`year`=year(${last_month})
ORDER BY
`forum_hottest_threads`.`rank` ASC
LIMIT 10