mysql分组后获取最大值的记录

项目亲测,百万条数据瞬间获取


select a.* from table_test a ,(select b.gcol,max(b.id) maxid from table_test b group by b.gcol )c where c.maxid = a.id


猜你喜欢

转载自blog.csdn.net/jiangxuexuanshuang/article/details/50614362