标签:item sum ati set lfs join mon seo itemid
----引入函数
set nocount on
declare @fbillno varchar
set @fbillno=‘*FBILLNOCOMMON*‘
----引入内码表
select finterid
into #temp01
from seorder
where FCancellation=0 and fbillno like ‘%*FBILLNOCOMMON*%‘
----主程序
SELECT a.fname ,b.FName,b.FBillNo , SUM(a.FQty) AS FQty
FROM (select a.FInterID ,a.FBillNo, c.fname , b.FSourceInterId , b.FSourceEntryID ,b.fitemid ,b.fqty
from poorder a
left join POOrderEntry b on b.FInterID=a.FInterID
left join t_Supplier c on c.fitemid=a.FSupplyID
where b.FSourceInterId in (select finterid
from #temp01
) ) a
left join (select b.FInterID ,b.FEntryID ,b.fitemid ,c.fname, d.fbillno
from seorderentry b
left join SEOrder d on d.FInterID=b.finterid
left join t_submessage c on c.FInterID=b.FEntrySelfS0162
) b on b.finterid=a.FSourceInterId and b.FEntryID=a.FSourceEntryID
GROUP BY a.fname , b.FName,b.FBillNo
d
----结束
drop table #temp01
标签:item sum ati set lfs join mon seo itemid
原文地址:https://www.cnblogs.com/qiugy/p/13589946.html