|
(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
|
|
-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 -- 自由项+合计数量做匹配
|
|
) 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 -- 自由项+合计数量做匹配
|
|
GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
|
|
GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
|