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

 

posted @ 2021-10-28 11:22  君子笑而不语  阅读(2277)  评论(0编辑  收藏  举报