利用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;
版权声明:本文为w851685279原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。