jQuery火箭图标返回顶部代码 - 站长素材

mysql分组取前5,类似sql server的partition by

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

 此外记录一下 sqlserver `partition by` 用法:

SELECT col ...n,
  row_number() over (partition by colx ORDER BY colz)
FROM tablename;

  

posted @ 2021-03-30 17:35  bincooo  阅读(287)  评论(0)    收藏  举报