|
@@ -37,10 +37,10 @@ group by pbv.cDefine10,pbvs.cInvCode,pbvs.cFree1,pbvs.cFree2,pbv.cBusType,inv.cI
|
|
having ommo.ccode like CONCAT(#{code},'%') AND pbv.cBusType='委外加工' and inv.cInvCCode like '19%') as pbv
|
|
having ommo.ccode like CONCAT(#{code},'%') AND pbv.cBusType='委外加工' and inv.cInvCCode like '19%') as pbv
|
|
left join
|
|
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
|
|
|
|
|
|
+(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,sbvs.cDefine28 as cDefine28
|
|
from UFDATA_101_2021.dbo.SaleBillVouchs sbvs left join UFDATA_101_2021.dbo.SaleBillVouch sbv on sbv.SBVID=sbvs.SBVID
|
|
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,sbvs.cDefine28
|
|
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 -- 自由项+合计数量做匹配
|
|
|
|
|
|
+) 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 and pbv.cdefine28 = sbv.cDefine28 -- 自由项+合计数量做匹配
|
|
LEFT JOIN UFDATA_101_2021.dbo.Vendor v ON pbv.cVenCode= v.cVenCode
|
|
LEFT JOIN UFDATA_101_2021.dbo.Vendor v ON pbv.cVenCode= v.cVenCode
|
|
GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
|
|
GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
|
|
|
|
|