程序代码:
SELECT Qyjjlxk.jjlxMC,CAST(COUNT(distinct Qyzycpk.jgmc) AS N(2)) 企业数,;
CAST(COUNT(QYZYCPK.ZYCP) AS N(2)) 产品数,;
CAST(SUM(IIF(QYZYCPK.BZDJ=[1],1,0)) AS N(2)) 国标,;
CAST(SUM(IIF(QYZYCPK.BZDJ=[2],1,0)) AS N(2)) 行标,;
CAST(SUM(IIF(QYZYCPK.BZDJ=[3],1,0)) AS N(2)) 地标,;
CAST(SUM(IIF(QYZYCPK.BZDJ=[4],1,0)) AS N(2)) 企标,;
CAST(SUM(IIF(QYZYCPK.BZDJ=[5],1,0)) AS N(2)) 协议 ;
FROM QYJBXXB ;
INNER JOIN QYJJLXK ;
ON QYJBXXB.JJLX=QYJJLXK.JJLX ;
INNER JOIN QYZYCPK ON Qyjbxxb.jgdm = Qyzycpk.jgdm GROUP BY Qyjjlxk.jjlxMC INTO CURSOR TEMP READWRITE
*--- 在数据表最后插入一条记录
INSERT INTO TEMP ((FIELD(1))) VALUES (PADC("合计",FSIZE(FIELD(1)),[ ]))
*---下面的代码好处,不管你有多少数值型字段,也不需要你知道字段名,全部计算合计数
FOR I=1 TO FCOUNT()
MFIELD=FIELD(I)
IF TYPE(MFIELD)="N"
*--- 数值型字段求和,并将结果添加到最后一条记录
SUM &MFIELD TO HJ
REPLACE RECORD RECCOUNT() (FIELD(I)) WITH HJ
*--- 清空数值型字段内容为"0"的记录
BLANK FIELD &MFIELD FOR &MFIELD=0
ENDIF
ENDFOR
*---或者用下面的代码
INSERT INTO TEMP SELECT [合计],SUM(企业数),SUM(产品数),SUM(国标),SUM(行标),SUM(地标),SUM(企标),SUM(协议) FROM TEMP
BROWSE
图片附件: 游客没有浏览图片的权限,请
登录 或
注册