|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册账号
×
数据库追踪的语句到这里就停止了
Insert into IA_subsidiary (bRdFlag,dvoudate,dKeepDate,iYear,iMonth,cInvHead,cVouType,cWhCode,cInvCode,
iAInQuantity,iInCost,iAInPrice,cAccounter,cMaker,cPzID,cfree1,cfree2,cfree3,cfree4,cfree5,cfree6,cfree7,cfree8,cfree9,cfree10,cBatchIA,cDefine7)
SELECT 1,'2023-12-31','2024-01-01',2024 as iyear,0 as imonth,IA_Subsidiary_Pre.cInvHead, N'34' As cVouType, IA_Subsidiary_Pre.cWhCode,
IA_Subsidiary_Pre.cInvCode,
IA_Subsidiary_Pre.SumQ, cast(str(case when IA_Subsidiary_Pre.cValueType=N'计划价法' or IA_Subsidiary_Pre.cValueType=N'售价法' then InvCheckFreeIA870.fInvRCost else (case when IA_Subsidiary_Pre.SumQ<>0 then IA_Subsidiary_Pre.SumM/IA_Subsidiary_Pre.SumQ else 0 end) end,38,3) as float),
IA_Subsidiary_Pre.SumM,null,N'主管审核','0',
IA_Subsidiary_Pre.cfree1,IA_Subsidiary_Pre.cfree2,IA_Subsidiary_Pre.cfree3,IA_Subsidiary_Pre.cfree4,IA_Subsidiary_Pre.cfree5,IA_Subsidiary_Pre.cfree6,
IA_Subsidiary_Pre.cfree7,IA_Subsidiary_Pre.cfree8,IA_Subsidiary_Pre.cfree9,IA_Subsidiary_Pre.cfree10,cBatchIA,null
FROM (SELECT IA_Subsidiary.cWhCode,N'34' as cVouType,N'' as cDepCode,
IA_Subsidiary.cInvCode,IA_Subsidiary.cInvHead,1 as PZID,cfree1,cfree2,cfree3,cfree4,cfree5,cfree6,cfree7,cfree8,cfree9,cfree10,cBatchIA,
Warehouse.cWhvaluestyle as cvaluetype,bcheckfree1,bcheckfree2,bcheckfree3,bcheckfree4,bcheckfree5,bcheckfree6,bcheckfree7,bcheckfree8,bcheckfree9,bcheckfree10,
cast(str(Sum(IsNull(IA_Subsidiary.iAInQuantity,0)-IsNull(IA_Subsidiary.iAOutQuantity,0)),38,3) as float) AS SumQ,
Sum(Cast(ISNULL(IA_Subsidiary.iAInPrice,0)-ISNULL(IA_Subsidiary.iAOutPrice,0) As Decimal(38,2))) AS SumM
FROM IA_Subsidiary IA_Subsidiary with (nolock)
inner join warehouse warehouse with (nolock) on IA_Subsidiary.cwhcode=warehouse.cwhcode
inner join Inventory Inventory with (nolock) on IA_Subsidiary.cInvCode = Inventory.cInvCode
WHERE Warehouse.cWhvaluestyle<>N'个别计价法' and Warehouse.cWhvaluestyle<>N'先进先出法' and Warehouse.cWhvaluestyle<>N'后进先出法'
And IA_Subsidiary.iYear = 2023 AND (IA_Subsidiary.iMonth>0 or (IA_Subsidiary.iMonth=0 and IA_Subsidiary.cVouType=N'34'))
GROUP BY IA_Subsidiary.cWhCode,
IA_Subsidiary.cInvCode,IA_Subsidiary.cInvHead,cfree1,cfree2,cfree3,cfree4,cfree5,cfree6,cfree7,cfree8,cfree9,cfree10,cBatchIA,
Warehouse.cWhvaluestyle,bcheckfree1,bcheckfree2,bcheckfree3,bcheckfree4,bcheckfree5,bcheckfree6,bcheckfree7,bcheckfree8,bcheckfree9,bcheckfree10
having cast(Sum(IsNull(IA_Subsidiary.iAInQuantity,0)-IsNull(IA_Subsidiary.iAOutQuantity,0)) as decimal(38,3))<>0 or
cast(Sum(ISNULL(IA_Subsidiary.iAInPrice,0)-ISNULL(IA_Subsidiary.iAOutPrice,0)) as decimal(38,2))<>0
) IA_Subsidiary_Pre left join InvCheckFreeIA870 InvCheckFreeIA870 with (nolock) on IA_Subsidiary_Pre.cinvcode=InvCheckFreeIA870.cinvcode
and (isnull(bcheckfree1,0)=0 or IA_Subsidiary_Pre.cfree1=InvCheckFreeIA870.cfree1) and (isnull(bcheckfree2,0)=0 or IA_Subsidiary_Pre.cfree2=InvCheckFreeIA870.cfree2)
and (isnull(bcheckfree3,0)=0 or IA_Subsidiary_Pre.cfree3=InvCheckFreeIA870.cfree3) and (isnull(bcheckfree4,0)=0 or IA_Subsidiary_Pre.cfree4=InvCheckFreeIA870.cfree4)
and (isnull(bcheckfree5,0)=0 or IA_Subsidiary_Pre.cfree5=InvCheckFreeIA870.cfree5) and (isnull(bcheckfree6,0)=0 or IA_Subsidiary_Pre.cfree6=InvCheckFreeIA870.cfree6)
and (isnull(bcheckfree7,0)=0 or IA_Subsidiary_Pre.cfree7=InvCheckFreeIA870.cfree7) and (isnull(bcheckfree8,0)=0 or IA_Subsidiary_Pre.cfree8=InvCheckFreeIA870.cfree8)
and (isnull(bcheckfree9,0)=0 or IA_Subsidiary_Pre.cfree9=InvCheckFreeIA870.cfree9) and (isnull(bcheckfree10,0)=0 or IA_Subsidiary_Pre.cfree10=InvCheckFreeIA870.cfree10)
-----------------------------------------------------------------------------------------------------*-----------------------------------------------------------------------------------------------
求助大神月末月末结账的提示:
|
|