Gossamer
Active member
I'm trying to write a query to get the number of posts from each user from the last month, but this isn't pulling up any results. I know there's something wrong with my WHERE statement, but I haven't found something that works yet. I don't want to hard-code in dates to check between, because I want to pull up this information regularly over time. My goal is to make these subqueries of a larger query that will show posting #s by month over the past year.
Any help would be appreciated. Thank you!
Code:
SELECT user_id,
username,
COUNT(post_id)
FROM xf_post
WHERE post_date BETWEEN DATE_SUB(NOW(), INTERVAL 1 MONTH) AND DATE_SUB(NOW(), INTERVAL 2 MONTH)
GROUP BY user_id
ORDER BY username
Any help would be appreciated. Thank you!