
Originally Posted by
Codiah
I posted this on a few sites hoping for a quick response and you're the only one that came through with a sensible answer.
OMG, how lame could those other sites be
your problem, and the solution, is at the novice level, there's nothing particularly difficult about it
by the way, you wanted month names, right?
you'll need to use this --
Code:
SELECT MONTHNAME(post_date) -- display this
, YEAR(post_date)
, COUNT(*)
, MONTH(post_date) -- and ignore this in the display
FROM posts
GROUP
BY YEAR(post_date)
, MONTH(post_date)
, MONTHNAME(post_date)
ORDER
BY YEAR(post_date)
, MONTH(post_date)
notice that in order to include MONTHNAME in the SELECT clause, you need to include it in the GROUP BY clause
actually, you don't need both MONTHNAME and MONTH in the GROUP BY clause in mysql, but ignore this non-standard anomaly for now
you do, however, need to include MONTH in the ORDER BY clause (so as to get the proper sequencing), and therefore you also need to include it in the SELECT clause
maybe a bit beyond novice level after all...
Bookmarks