SELECT user.username, COUNT(articles.thread_id) AS article_countFROM xf_user AS user
INNER JOIN xf_user_profile AS user_profile
ON (user.user_id = user_profile.user_id)
INNER JOIN ewrporta2_catlinks AS catlinks
ON (catlinks.user_id = user.user_id)
INNER JOIN ewrporta2_articles AS articles
ON (articles.thread_id = catlinks.thread_id)
WHERE MONTH(CURDATE() articles.article_date between DATE_FORMAT(NOW() - INTERVAL 1 MONTH,'%Y-%m-01 00:00:00') AND DATE_FORMAT(LAST_DAY(NOW() - INTERVAL 1 MONTH), '%Y-%m-%d 23:59:59')
GROUP BY user.user_id