非常感谢各位的无私付出,现附上VFP6.0的代码,一是VFP9.0和6.0 都有了,二来表示这个贴子也有个结果,三来恳请高手给予点评、修改。
*****VFP6.0***
CLOSE ALL
set talk off
set safety off
use qq
ALIAS qq IN 0
index on ALLT(部门) tag 部门
sele 部门
from qq group by 部门 into tabl bmb
sele bmb
cstr=""
scan
cstr=cstr+allt(部门)+" N(10,2),"
endscan
cstr=left(cstr,len(cstr)-1)
create TABL BM (部门 C(10),DM C(2),&cstr,hj n(12,2))
append from GZB fields 部门,DM
*index on 部门 tag 部门
sele BM
FOR I=3 TO FCOUNT()
FN=FIELD(I)
scan
ZDM=ALLT(BM.部门)
if BM.部门='人数'
SELE COUNT(*) FROM QQ WHERE
QQ.部门=FN INTO ARRAY RS
REPL &FN
WITH RS
ENDIF
SELE
QQ
if fsize('&ZDM')>0
SUM(&ZDM) TO QN FOR QQ.部门=FN
SELE BM
REPL &FN
WITH QN
Endif
ENDscan
endfor
SELE BM
nfield=''
for i=3 to fcount()
nfield=nfield+field(i)+"+"
endfor
nfield=left(nfield,len(nfield)-1)
repl all hj with &nfield
use
use bm
brow
[此贴子已经被作者于2017-4-24 20:05编辑过]