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