- for: Query Lot HISTORY
--When to use: if you are Tracing bug in Production Database, this SQL CAN HELP You to TRACE The Activity of The Lot.
Select T.Activity, H.GrouphistKey, Sh.Handle, Substr (Sh.Stepid, 1, INSTR (SH.STEPID, '.') - 1),
H. LastLocation, H.lotquantity, T.TxntimeStamp, T.Userid, C.Briefscription, C.commentCode, T. *
From fwwiptransaction t, fwwiPhistory h, fwiphistory_n2m hn, fwipstephistory sh, fwcomment c
Where t.wipid = 'agza1f4c0090.01' and h.wiptxn ( ) = t.sysid
And h.sysid = hn.fromid ( ) and hn.toid = sh.sysid ( ) and c.sysid ( ) = T.TXNComment
Order by t.txntimestamp desc