方法一:
CLOSE DATABASES
USE sj IN 0
SELECT distinct 类别 FROM sj INTO CURSOR sj_tmp
SELECT sj_tmp
SCAN
SET FILTER TO ALLTRIM(类别)==ALLTRIM(sj_tmp.类别) IN SJ
GO TOP IN sj
i=0
SELECT sj
SCAN
i=i+1
REPLACE 序号 WITH i IN sj
ENDSCAN
SET FILTER TO IN SJ
SELECT sj_tmp
ENDSCAN
CLOSE DATABASES
---------------------------
方法二:
CLOSE DATABASES
USE sj EXCLUSIVE
IN 0
SELECT *,RECNO() ID FROM (SELECT * FROM SJ ORDER BY 类别,考号) A
INTO CURSOR SJ_TMP READWRITE
UPDATE SJ_TMP SET 序号=SJ_TMP.ID-b.ID+1 from (select 类别,MIN(ID) ID from sj_TMP group by 类别 ) b WHERE sj_TMP.类别==b.类别
ZAP IN sj
SELECT sj
APPEND FROM (DBF('sj_tmp'))
CLOSE DATABASES
[
本帖最后由 kiff 于 2013-4-3 07:46 编辑 ]