select * from (
select if(@utype = a.utype, @nu := @nu+1, @nu:=1) as nu, @utype := a.utype, a.* from secuser a order by a.utype,a.id desc
) T where T.nu <= 5
mysql分组取前5,类似sql server的partition by
最新推荐文章于 2023-02-23 13:56:46 发布
select * from (
select if(@utype = a.utype, @nu := @nu+1, @nu:=1) as nu, @utype := a.utype, a.* from secuser a order by a.utype,a.id desc
) T where T.nu <= 5