这段程序代码错在哪儿?
有三个数据库表,结构及记录如下:1、经济类型分类代码表(qyjjlxk.dbf)
2、企业基本信息表(qyjbxxb.dbf)
3、企业主要产品表(qyzycpk.dbf)
希望统计各种经济类型企业执行标准情况,于是编写了如下一段代码,可是运行结果并非自己想要的。如图:
本来,在数据表中,“私营有限责任公司”这类中有1个企业、4个产品,“个体经营”这类中有5个企业、5个产品,可统计结果却完全不是这样。为什么?代码如下,请各位老师帮忙看看,不胜感激!
程序代码:
SET ESCAPE OFF SELECT b USE qyjjlxk IF .not.file('jjlxsy.idx') INDEX on jjlx TO jjlxsy ELSE SET INDEX TO jjlxsy REINDEX ENDIF SELECT c USE qyzycpk IF .not.file('cpsy.idx') INDEX on jgdm TO cpsy ELSE SET INDEX TO cpsy REINDEX ENDIF SELECT a USE qyjbxxb IF .not.file('jjlssy.idx') INDEX on jjlx TO jjlssy ELSE SET INDEX TO jjlssy REINDEX ENDIF SET RELATION TO jjlx INTO qyjjlxk SET RELATION TO jgdm INTO qyzycpk additive GO top TOTAL TO lxk.dbf ON jjlx USE lxk SET RELATION TO jjlx INTO qyjjlxk additive COUNT ALL TO lxsl GO top j=lxsl DIMENSION lx(j),lm(j) j=1 DO whil .not.eof() lx(j)=jjlx lm(j)=b->jjlxmc j=j+1 SKIP ENDDO USE qyjbxxb ERASE lxk.dbf DIMENSION dm(j) j=1 STORE 0 TO hj1,hj2,hj3,hj4,hj5,hj6,hj7,hj8 DO WHILE j<=lxsl SET FILTER TO jjlx=lx(j) dm(j)=jgdm COUNT FOR jjlx=lx(j) TO aa SELECT c COUNT ALL FOR jgdm=dm(j) TO bb COUNT ALL FOR jgdm=dm(j).and.bzdj='1' TO cc COUNT ALL FOR jgdm=dm(j).and.bzdj='2' TO dd COUNT ALL FOR jgdm=dm(j).and.bzdj='3' TO ee COUNT ALL FOR jgdm=dm(j).and.bzdj='4' TO ff COUNT ALL FOR jgdm=dm(j).and.bzdj='5' TO gg hh=ROUND((cc+dd+ee+ff+gg)/bb*100,2) hj1=hj1+aa hj2=hj2+bb hj3=hj3+cc hj4=hj4+dd hj5=hj5+ee hj6=hj6+ff hj7=hj7+gg hj8=ROUND((hj3+hj4+hj5+hj6+hj7)/hj2*100,2) j=j+1 SELECT a SET FILTER TO ENDDO