这个意思吗?
Close Databases 
Use 编排
*!*    Blank all Fields 小组, 序号
Select 大组,轮次,性别, Cast(0 as I) as 小组 ;
    from 编排 group by 大组,轮次,性别 into cursor grp Readwrite
Update grp set 小组 = Recno()
Select grp
Locate
m.n大组 = 大组
m.n小组 = 1
Scan all
    Scatter name oo
    If 大组 != m.n大组
        m.n大组 = 大组
        m.n小组 = 1
    EndIf
    
    Select 大组,轮次,姓名,性别,序号,小组 ;
        from 编排 ;
        where 大组 = m.oo.大组 and 轮次 = m.oo.轮次 and 性别 = m.oo.性别 ;
        into cursor temp Readwrite
    Update temp set 序号 = 1+Mod(Recno()-1, 18), 小组 = m.n小组+Int((Recno()-1)/18)
    m.n小组 = 1 + 小组
    
    Update t set t.小组 = s.小组, t.序号 = s.序号 ;
        from 编排 t inner join temp s on ;
                t.大组 = s.大组 ;
            and t.轮次 = s.轮次 ;
            and t.性别 = s.性别 ;
            and t.姓名 = s.姓名
    
EndScan
Use in temp
Use in grp
[此贴子已经被作者于2022-8-5 18:03编辑过]