花名单中WHCD中的技校算什么学历,故有17楼之问
[此贴子已经被作者于2016-12-19 01:02编辑过]

坚守VFP最后的阵地
程序代码:Close Databases all
Select xm,bm,whcd,dm from 花名单,标准 where 花名单.whcd==标准.文化程度 into cursor hmd
Select distinct bm from 花名单 into array ajg
* 创建临时表结构及索引
lcstr=""
for lnI=1 to alen(ajg,1)
lcstr=lcstr+iif(empty(lcstr),"",",")+alltrim(ajg[lnI,1])+" N(3)"
endfor
create cursor tjb (文化程度 c(20),dm c(2),人数 n(4),&lcstr)
Append From 表1 fields 文化程度,dm
index on dm tag xl
* 数据处理
select hmd
set relation to dm into tjb
Scan
bm1=Alltrim(bm)
Replace (bm1) with Evaluate(bm1)+1 in tjb
EndScan
set relation to
Select tjb
For i=1 to 6
=tj(i)
endfor
browse
******** 自定义函数 ********
Function tj
Parameters ii
Select tjb
Local asj[6,Fcount()-3]
* 设置统计条件
Do case
Case ii=1
ctj='Between(dm,"03","05")'
n=2
Case ii=2
ctj='Between(dm,"08","09")'
n=8
Case ii=3
ctj='Between(dm,"11","12")'
n=10
Case ii=4
ctj='inlist(dm,"07","08","10")'
n=6
Case ii=5
ctj='Between(dm,"14","15")'
n=13
Case ii=6
ctj='inlist(dm,"02","06","13")'
n=1
EndCase
* 列人数合计
For j=4 to Fcount()
Sum evaluate(Field(j)) to asj[ii,j-3] for &ctj
replace (Field(j)) with asj[ii,j-3] for Recno()=n
EndFor
* 行人数合计
If ii=6
cstr=""
For iii=4 to Fcount()
cstr=cstr+"+"+(Field(iii))
EndFor
Replace all 人数 with Evaluate(cstr)
EndIf

