CASE WHEN (LOT.LOT_LotQty IS NOT NULL ) THEN (LOT.LOT_LotQty - isnull((
select sum(ITL.ITL_LotQty)
from ITL
where LOT.LOT_ID = ITL.ITL_LOT_ID
-- As Of Date Criteria
and ITL_ITR_ID in (select GLL_ID
from GL_TransLine(NOLOCK)
inner join GL_Trans(NOLOCK) ON GLT_TransID = GLL_TransID
where GLT_TransDate > @AsOfDate
and GLL_ItemID = IMA_ItemID
)
คุณ TC Admin ครับ ผมลอง Test ตาม Code ด้านล่างแล้วครับ เวลาช้ากว่ากันประมาณ 10-15 Sec. ครับ
ผมลอง TEST เป็นCode (SQL)
SELECT sum(ITL.ITL_LotQty)-- ITL.ITL_ITR_ID
FROM ITL INNER JOIN
LOT ON dbo.ITL.ITL_LOT_ID = dbo.LOT.LOT_ID
where LOT.LOT_ID = ITL.ITL_LOT_ID
-- As Of Date Criteria
and ITL_ITR_ID in (select GLL_ITR_ID --GLL_ItemID,
from GL_TransLine(NOLOCK)
inner join GL_Trans(NOLOCK) ON GLT_TransID = GLL_TransID
where GLT_TransDate > @AsOfDate
and GLL_ItemID = IMA_ItemID )
Code ด้านล่างตัวนี้ก็ช้าครับ ตัวที่ Post สอบถามจะเร็วกว่า 15-20 Sec. ครับ Code (SQL)
WHEN (LOC.LOC_LocQty IS NOT NULL ) THEN (LOC.LOC_LocQty - isnull((
select sum(ITC.ITC_LocQty)
from ITC
INNER JOIN (
select
LOC_ID
from LOC
group by LOC_ID--ITC_LOC_ID
)as M
ON ITC.ITC_LOC_ID=M.LOC_ID--ITC_LOC_ID
inner join LOC
on ITC.ITC_LOC_ID = dbo.LOC.LOC_ID
and ITC_ITR_ID in (select GLL_ITR_ID
from GL_TransLine
inner join GL_Trans ON GLT_TransID = GLL_TransID
where GLT_TransDate > @AsOfDate --@AsOfDate
and GLL_ItemID = IMA_ItemID)