http://download.
CLOSE ALL
CLEAR
USE TBL1 IN 0
USE TBL2 IN 1
SQL_STR=''
CSTR=''
SELECT A.*,B.BMMC FROM TBL1 A LEFT JOIN TBL2 B ON A.BMBH=B.BMBH INTO CURSOR CUR_TMP
SQL_STR=[SELECT RQ,PZBH,JFJE,DFJE,BMBH]
SELECT [,IIF(BMMC=']+BMMC+[',JFJE-DFJE,00000)]+[ ]+BMMC AS STR_C FROM TBL2 INTO CURSOR TMP
FOR I = 1 TO RECCOUNT()-1
GO I
CSTR=CSTR+ALLTRIM(STR_C)
ENDFOR
*?CSTR
SQL_STR=SQL_STR+CSTR+' FROM CUR_TMP M'
*?SQL_STR
EXECSCRIPT(SQL_STR)
经过反复测试,6楼的代码在最后的循环中多了一次,目标表多出了一列空列,要改成上面(红字是改动部份)才行。