目前还没找到完美的解决方案
https://dev.mysql.com/doc/refman/5.6/en/example-maximum-column-group-row.html
http://stackoverflow.com/questions/1066453/mysql-group-by-and-order-by
https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html
这个貌似解决了,还得再理解一下。。。
http://www.educity.cn/wenda/404337.html
--三、按name分组取第一次出现的行所在的数据。
select a.*from tb a where val = (selecttop1 val from tb where name = a.name) orderby a.name
本文探讨了在MySQL中如何按特定字段进行分组并选取每个分组中的最大行,提供了实现这一目标的具体SQL语句实例,并引用了多个参考资料。
959

被折叠的 条评论
为什么被折叠?



