SQL 语句如下:
SELECT A.LBBM LBBM,A.LBDM TYBH, A.LBMC LB,A.JSDW JSDW,B.SL SL,B.YZ YZ FROM
(SELECT LBBM,LBDM,LBMC,JSDW FROM ZCLBB WHERE LEN(LBBM)=1) A LEFT JOIN
(SELECT COUNT(*) SL,SUM(YZ) YZ FROM GDZCTZB WHERE JKRQ>=:STIME AND JKRQ <=:ETIME AND JSDH='') B ON 1=1
UNION
SELECT A.LBBM LBBM,A.LBDM TYBH, A.LBMC LB,A.JSDW JSDW,B.SL SL,B.YZ YZ FROM
(SELECT LBBM,LBDM,LBMC,JSDW FROM ZCLBB WHERE LEN(LBBM)=2) A LEFT JOIN
(SELECT LB,COUNT(LB) SL,SUM(YZ) YZ FROM GDZCTZB WHERE JKRQ>=:STIME AND JKRQ<=:ETIME AND JSDH='' GROUP BY LB) B ON A.LBMC=B.LB
ORDER BY A.LBBM
帮忙分析一下,那里出错了。。。 |