select Id, row_number() over (partition by WoCode order by WoCode) as group_idx from AmsWorkBill_WoCommand