开发者

mysql - getting the last 10 unique months

I want to get the last 10 unique months where there have been events, stored as event_date as a mysql date. I am using coldfusion so could group the result but can't get that working as I would like.

This is what I have so far.

SELECT MONTH(event_date) AS month, YEAR(event_date) AS year, event_date from events

so ideally if there wer开发者_StackOverflowe no posts in August would be output as

september 2010 july 2010 june 2010 may

etc etc

Thanks.

R.


SELECT DISTINCT MONTH(event_date) AS month, YEAR(event_date) AS year from events ORDER BY year DESC, month DESC LIMIT 10;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜