表的操作 , 各位大神帮忙
表 : flag total a1 a2 a3 a4 a5 a6 a7 a8 11011101 388 61 51 20 63 58 75 0 80
11110011 355 45 60 75 80 25 10 65 30
取 a1 到 a8最大六个值, 将flag相应标志置为1,其他两位置为0,将total置为最大六个值得总和
CREATE CURSOR TABNAME1 (FALG C(8),TOTAL N(4),值 N(2),标志 C(1),最大值 N(4)) CREATE CURSOR TABNAME (FALG C(8),TOTAL N(4),A1 N(2),A2 N(2),A3 N(2),A4 N(2),A5 N(2),A6 N(2),A7 N(2),A8 N(2)) INSERT INTO TABNAME VALUES ("11011101",388,61,51,20,64,58,75,0,80) INSERT INTO TABNAME VALUES ("11110011",355,45,60,75,80,25,10,65,30) GO TOP SCAN SCATTER FIELDS LIKE A* TO TABARRAY ASORT(TABARRAY) N_SUM=0 FOR I=1 TO FCOUNT("TABNAME")-2 IF I>2 N_SUM=N_SUM+TABARRAY(I) ENDIF INSERT INTO TABNAME1 VALUES (TABNAME.FALG,TABNAME.TOTAL,TABARRAY(I),IIF(I<=2,"0","1"),0) ENDFOR REPLACE 最大值 WITH N_SUM IN TABNAME1 ENDSCAN SELECT TABNAME1 BROWSE