我在写MySQL查询时遇到了问题。 我在DB获取MySQL中每个月的最后一个记录....?
id created_on status
1 2011-02-15 12:47:09 1
2 2011-02-24 12:47:09 1
3 2011-02-29 12:47:09 1
4 2011-03-11 12:47:09 1
5 2011-03-15 12:47:09 1
6 2011-03-22 12:47:09 1
7 2011-04-10 12:47:09 1
8 2011-04-11 12:47:09 1
以下字段我需要select the last record of each month
。 这对于month FEB record # 3
month MARCH record # 6
和month APRIL record # 8
请帮我.....
在此先感谢.....
[我可以在mysql中使用聚合函数(LAST)吗?](http://stackoverflow.com/questions/5495913/can-i-use-aggregation-function-last-in-mysql) – 2011-04-11 13:23:24
检查我发布的答案。我相信它会回答你的问题。 – reggie 2011-04-11 13:38:14
查看http://stackoverflow.com/questions/1379565/mysql-first-and-last-record-of-a-grouped-record-aggregate-functions中接受的答案以获得更高效的解决方案 – eyaler 2012-06-25 12:45:49