Bootstrap

mysql8.0分组后取最新一条

 利用mysql8.0的窗口函数

select * from(
  select row_number() over (partition by 分组字段 order by 排序字段 desc) as rn,u.*
  from 表名 u 
) t where t.rn=1;

例如: 

select * from(
  select row_number() over (partition by tel order by delete_time desc) as rn,u.*
  from user u 
) t where t.rn=1;

 

;