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

作者:Logan
Q Q:511570155
    
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/Logan626/p/14541399.html