回复 19楼 jinanshui
用了点时间写完了,同分数同名次LOCAL lcField,lcSQL
lcField = ""
SELECT CJ
FOR m.i= 3 TO 12
TEXT TO m.lcField ADDITIVE NOSHOW TEXTMERGE
<<FIELD(m.i)>>,00000 AS <<FIELD(m.i)>>班名次,00000 AS <<FIELD(m.i)>>总名次,
ENDTEXT
ENDFOR
m.lcSQL = "SELECT 学号,SUBSTR(学号,3,2) AS 班级,姓名,"+LEFT(m.lcField,LEN(m.lcField)-1)+" FROM CJ INTO CURSOR CJPM READWRITE"
EXECSCRIPT(m.lcSQL)
SELECT CJ
FOR m.i= 3 TO 12
TEXT TO m.lcSQL NOSHOW TEXTMERGE
SELECT 班级,<<FIELD(m.i)>>,00000 AS <<FIELD(m.i)>>班名次 FROM CJPM GROUP BY 班级,<<FIELD(m.i)>> ORDER BY 班级,<<FIELD(m.i)>> DESC INTO CURSOR TempCursor READWRITE
UPDATE TempCursor SET <<FIELD(m.i)>>班名次 = RECNO()
UPDATE TempCursor SET <<FIELD(m.i)>>班名次 = RECNO()-启始 from (SELECT 班级,MIN(<<FIELD(m.i)>>班名次)-1 启始 FROM TempCursor GROUP BY 班级) A WHERE TempCursor.班级=A.班级
UPDATE CJPM SET <<FIELD(m.i)>>班名次 = TempCursor.<<FIELD(m.i)>>班名次 FROM TempCursor WHERE CJPM.班级 = TempCursor.班级 AND CJPM.<<FIELD(m.i)>> = TempCursor.<<FIELD(m.i)>>
SELECT <<FIELD(m.i)>>,00000 AS <<FIELD(m.i)>>总名次 FROM CJPM GROUP BY <<FIELD(m.i)>> ORDER BY <<FIELD(m.i)>> DESC INTO CURSOR TempCursor READWRITE
UPDATE TempCursor SET <<FIELD(m.i)>>总名次 = RECNO()
UPDATE CJPM SET <<FIELD(m.i)>>总名次 = TempCursor.<<FIELD(m.i)>>总名次 FROM TempCursor WHERE CJPM.<<FIELD(m.i)>> = TempCursor.<<FIELD(m.i)>>
ENDTEXT
EXECSCRIPT(m.lcSQL)
SELECT CJ
ENDFOR
SELECT CJPM
BROWSE
[此贴子已经被作者于2024-2-21 09:35编辑过]