回S版:
非常感谢!斑斑的耐心指教,使我初步认识到SQL命令的强大功能,关键在于灵活运用。
最后一个子问题:“标准覆盖率”项的计算还是不知如何弄
非常感谢!斑斑的耐心指教,使我初步认识到SQL命令的强大功能,关键在于灵活运用。
最后一个子问题:“标准覆盖率”项的计算还是不知如何弄
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)) 协议,; ROUND((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)))/(CAST(COUNT(QYZYCPK.ZYCP) AS N(2)))*100,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 SELECT [合计],SUM(企业数),SUM(产品数),SUM(国标),SUM(行标),SUM(地标),SUM(企标),SUM(协议),; ROUND((SUM(国标)+SUM(行标)+SUM(地标)+SUM(企标)+SUM(协议))/SUM(产品数)*100,2) FROM TEMP GO TOP WITH THISFORM.GRID1 .COLUMNCOUNT=FCOUNT([TEMP]) .SETALL([FORMAT],[Z],[COLUMN]) .RECORDSOURCE=[TEMP] FOR I=1 TO .COLUMNCOUNT WITH .COLUMNS(I) .WIDTH=IIF(I=1,168,IIF(i=thisform.grid1.columncount,100,48)) .HEADER1.CAPTION=FIELD(I) .HEADER1.ALIGNMENT=2 .Resizable=.F. ENDWITH ENDFOR ENDWITH