create table jf_sa_fahuobiao (cCuscode VARCHAR(20), cCusName VARCHAR(98),isum money,qc money)
Insert into jf_sa_fahuobiao (ccuscode,cCusName,isum,qc)
--前面的都没问题
select DispatchList.cCuscode,DispatchList.cCusName, sum(DispatchLists.isum) isum from DispatchList right JOIN DispatchLists on DispatchList.DLID = DispatchLists.DLID WHERE (dDate >= CONVERT(DATETIME, '2009-11-17 00:00:00', 102)) and (dDate <= CONVERT(DATETIME, '2010-04-17 00:00:00', 102)), --这里出现一个逗句,where 语句后面条件分隔不是用逗号的。
<---
sum(DispatchLists.isum) qc
from DispatchList right JOIN DispatchLists on DispatchList.DLID = DispatchLists.DLID
WHERE (dDate < CONVERT(DATETIME, '2009-11-17 00:00:00', 102))
--> 这一块我估计你是重复了吧? 这一句好像没什么意义!
GROUP BY ccuscode,cCusName