UPDATE VS4TChequeSub Set TCHSChqPassDate=(select TOP 1 TGLTDate from vs4tgltrans where TGLTInputSource='PCQ' AND TGLTCancelStatus = 0 AND VS4TChequeSub.TCHSNo=vs4tgltrans.TGLTRefNo ORDER BY TGLTDate DESC,TGLTFlag3 DESC) WHERE TCHSChqStatus=2
GO

UPDATE VS4TChequeSub Set TCHSChqBackDate=(select TOP 1 TGLTDate from vs4tgltrans where TGLTInputSource='XPCQ' AND TGLTCancelStatus = 0 AND VS4TChequeSub.TCHSNo=vs4tgltrans.TGLTRefNo ORDER BY TGLTDate DESC,TGLTFlag3 DESC) WHERE TCHSChqStatus=3
GO
