|
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622 。
您需要 登录 才可以下载或查看,没有帐号?注册
x
我是SQL的初学者,下面这句话不知哪儿错了,请各位大哥帮帮忙,纠正一下
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)),
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
主要是想将dispatchlists中isum值按ccuscode分组求和,并按日期区间放到 jf_sa_fahuobiao表isum和qc 的字段中.请大家帮一下吧!
|
|