|
楼主 |
发表于 2009-10-20 09:42:40
|
显示全部楼层
各位对这份资料评价那么高,到底你们学到了多少?能使用了吗?
这是我针对我们公司的U872写的一个销售进销存查询表,你们看能不能改下为已用.
--新建视图XINHE_XXX01,取收发存汇总表中的数量,本公司这里为入库数
create view XINHE_XXX01 as
SELECT csocode, iorderseq, SUM(iQuantity) AS rq
FROM dbo.RdRecords
WHERE (copdesc LIKE '%全检')
GROUP BY csocode, iorderseq
--新建视图XINHE_XXX02 这个视图取收发子表中的发货数量
create view XINHE_XXX02 as
SELECT csocode, iorderseq, SUM(iNQuantity) AS fh
FROM dbo.RdRecords
WHERE (copdesc IS NULL)
GROUP BY csocode, iorderseq
--进销存查询报表语句
select
so_somain.dDate 制单日期,inventory.cInvDepCode 部门,so_sodetails.csocode 订单号,
iRowNo 行号,Customer.cCusAbbName 客户简称,inventory.cinvcode 存货编码,inventory.cinvname 存货名称,
inventory.cInvStd 规格型号,so_sodetails.cMemo 备注,so_sodetails.cdefine22 订单数量,so_sodetails.iQuantity 实收数量,
mom_orderdetail.qty 生产数量,xinhe_xxx01.rq 入库数量,xinhe_xxx02.fh 发货数量,xinhe_xxx01.rq-(case when xinhe_xxx02.fh is null then 0 else xinhe_xxx02.fh end)现存数量,
so_sodetails.dPreDate 成品交期
from so_sodetails
join so_somain on so_sodetails.csocode=so_somain.csocode
join customer on so_somain.ccuscode=customer.ccuscode
join inventory on so_sodetails.cinvcode=inventory.cinvcode
left join mom_orderdetail on so_sodetails.csocode=mom_orderdetail.SoCode and so_sodetails.irowno=mom_orderdetail.SoSeq
left join xinhe_xxx01 on so_sodetails.csocode=xinhe_xxx01.csocode and so_sodetails.irowno=xinhe_xxx01.iorderseq
left join xinhe_xxx02 on so_sodetails.csocode=xinhe_xxx02.csocode and so_sodetails.irowno=xinhe_xxx02.iorderseq
group by so_somain.dDate,inventory.cInvDepCode,so_sodetails.csocode,
iRowNo,Customer.cCusAbbName,inventory.cinvcode ,inventory.cinvname,
inventory.cInvStd,so_sodetails.cMemo,so_sodetails.cdefine22,so_sodetails.iQuantity,
mom_orderdetail.qty,xinhe_xxx01.rq,xinhe_xxx02.fh,so_sodetails.dPreDate |
|