数据库
首页 > 数据库> > MySQL实现分组排序并取组内第一条数据

MySQL实现分组排序并取组内第一条数据

作者:互联网

错误示范:

select t.* from (
    select * from error_record e order by e.begin_time desc
) t group by t.error_type

 

正确示范:

内部子查询用limit字段,可固定排序

select t.* from (
    select * from error_record e order by e.begin_time desc limit 1000
) t group by t.error_type

 

标签:begin,group,组内,time,并取,error,MySQL,type,select
来源: https://www.cnblogs.com/xiaoliu66007/p/15474735.html