SELECT MONTHNAME(date) as month, YEAR(date) as year, SUM(count) as count FROM pagehits GROUP BY YEAR(date), MONTHNAME(date) ORDER BY YEAR(date), MONTH(date)
I then need to limit this to the previous 12 months.
What's the best way to do this?
1) Using PHP (mktime, date) to get the defining months and plugging into the query
2) Using MySQL's built in functions (BETWEEN, DATE_SUB) to figure this out as part of the query (preferable I think)
I know there many different ways to go about this, I'm a little confused about putting the parts to work together.
Thanks,
-Lisi
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php