mysql 分组行号

select
id,
@group_row:=CASE when @parent_code=a.staff_id then @group_row+1 else 1 end as groupRow,
@parent_code:=a.staff_id as parent_code
from ss_staff_ctrt a ,( select @group_row:=1, @parent_code:='') as b
ORDER BY a.staff_id

posted @ 2021-03-16 09:01  Logan_626  阅读(135)  评论(0编辑  收藏  举报