我希望尝试动态返回自上次proc运行以来已创建的面板数,并返回这些新创建的面板批号。我认为我们每分钟运行一次proc。我玩
---,datediff(mi,0,STOALL.CREDATTIM_0) +1
--,STOALL.CREDATTIM_0
--,rows=count(1)
但是我想我缺少和平。任何建议将不胜感激,并在此先感谢。
SELECT
STOALL.VCRNUM_0,
STOCK.LOT_0,
STOALL.CREDAT_0,
STOALL.CREDATTIM_0
FROM
SANDBOX.MFGITM -- Finished good on work order
INNER JOIN
SANDBOX.MFGMAT ON MFGITM.MFGNUM_0 = MFGMAT.MFGNUM_0 -- Finished good materials
AND MFGITM.MFGLIN_0 = MFGMAT.MFGLIN_0
INNER JOIN
SANDBOX.MFGHEAD ON MFGITM.MFGNUM_0 = MFGHEAD.MFGNUM_0 -- Work order header
LEFT JOIN
SANDBOX.STOALL ON MFGMAT.MFGLIN_0 = STOALL.VCRLIN_0 -- Allocations
AND STOALL.VCRNUM_0 = MFGMAT.MFGNUM_0
LEFT JOIN
SANDBOX.STOCK ON STOALL.STOCOU_0 = STOCK.STOCOU_0 -- Stock
LEFT JOIN
SANDBOX.SORDERP ON SORDERP.SOHNUM_0 = MFGITM.VCRNUMORI_0 -- Sales order line price
AND SORDERP.SOPLIN_0 = MFGITM.VCRLINORI_0
LEFT JOIN
SANDBOX.SORDERQ ON SORDERQ.SOHNUM_0 = SORDERP.SOHNUM_0 -- Sales order line quantity
AND SORDERQ.SOPLIN_0 = SORDERP.SOPLIN_0
LEFT JOIN
SANDBOX.SORDER ON SORDERQ.SOHNUM_0 = SORDER.SOHNUM_0 -- Sales order header
LEFT JOIN
SANDBOX.ITMMASTER ON SANDBOX.MFGMAT.ITMREF_0 = SANDBOX.ITMMASTER.ITMREF_0
WHERE
ZSOSELECTED_0 = 2 -- Sales order header selection flag
AND YSELECTED_0 = 0 -- Work order header selection flag
AND ZBPSELECTION_0 = 2 -- Sales line selection flag
AND SANDBOX.ITMMASTER.TSICOD_0 = 'HOP01'
AND MFGHEAD.MFGSTA_0 <> 4
-- AND MFGHEAD.MFGNUM_0 = 'WO111-181413'
-- AND SANDBOX.STOALL.ALLTYP_0=2 --- flagged as allocation
-- AND VCRNUMORI_0='SC111-180481'