|
@@ -39,7 +39,7 @@ left join
|
|
|
-- 根据外销发票号 加物料编码以及自由项组合计算 销售发票合计数量
|
|
|
(select sbv.cDefine10,sum(sbvs.iQuantity) as iQuantity,sbvs.cInvCode,sbvs.cFree1,sbvs.cFree2,min(sbv.dDate) as dDate,max(sbv.iExchRate) as iExchRate,sbv.cSOCode as cSOCode,max(sbvs.iTaxUnitPrice) AS exportUnitPrice,sum(sbvs.iSum) as exportPrice,sum(sbvs.iNatSum) as rmbAmount,max(sbv.cexch_name) as cexch_name
|
|
|
from UFDATA_101_2021.dbo.SaleBillVouchs sbvs left join UFDATA_101_2021.dbo.SaleBillVouch sbv on sbv.SBVID=sbvs.SBVID
|
|
|
-group by sbv.cDefine10,sbvs.cInvCode,sbvs.cFree1,sbvs.cFree2,sbv.cSOCode
|
|
|
+group by sbv.cDefine10,sbvs.cInvCode,sbvs.cFree1,sbvs.cFree2,sbv.cSOCode,sbvs.cDefine28
|
|
|
) as sbv on sbv.cInvCode=pbv.cInvCode and sbv.cFree1=pbv.cFree1 and sbv.cFree2=pbv.cFree2 and pbv.iQuantity=sbv.iQuantity and pbv.cDefine10 = sbv.cDefine10 -- 自由项+合计数量做匹配
|
|
|
LEFT JOIN UFDATA_101_2021.dbo.Vendor v ON pbv.cVenCode= v.cVenCode
|
|
|
GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
|