I’m working on a blog in PHP/SQL etc and I have come across something I think is too advanced (obviously) for my SQL knowledge. I’m creating an archive section where, when posts are made, it stores the date/time of its post in UNIX timestamp format. However I want the archive to show like this:
Date Year Post Count
-------- ---- ----------
November 2011 2
December 2011 1
I can easily get this:
Date Year Post Count
-------- ---- ----------
November 2011 2
November 2011 2
December 2011 1
Hope you can see what I’m trying to achieve. My current SQL statement for this is:
SELECT `post_date` FROM `blog_posts` ORDER BY `post_date` DESC
PHP handles most of the sorting and there is a way I can achieve this in PHP but I’m sure there’s an easier way in SQL.
Hope someone can help.
For MySQL (5.5) it would be close to following:
Would return: