Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select distinct a.AuditID
- , i.InstitutionID
- , 0
- , 1
- , 0
- from tAudit a (index XIE4tAudit )
- , hInstitution i (index XPKhInstitution )
- , tInstRelation ir (index XIE1tInstRelation)
- where a.InDateTime >= dateadd(dd,-1,getdate())
- and a.Action in (1,2)
- and a.ObjectName = "tInstitution"
- and a.ObjectReference = 1
- and i.HistoryHeaderID = a.AuditID
- and i.PropDealPart = 0
- and i.MainMember = 1
- and ir.InstRelTypeID = 10000000010
- and ir.InstParentID = 10000000003
- and ir.InstChildID = i.InstitutionID
- and ir.DocCloseFlag = 0
- and ir.DateClose = '19000101'
- and a.InDateTime = (select min(a1.InDateTime)
- from tAudit a1 (index XIE4tAudit )
- , hInstitution i1 (index XPKhInstitution )
- , tInstRelation ir1 (index XPKtInstRelation)
- where a1.InDateTime >= dateadd(dd,-1,getdate())
- and a1.Action in (1,2)
- and a1.ObjectName = "tInstitution"
- and a1.ObjectReference = 1
- and i1.HistoryHeaderID = a1.AuditID
- and i.InstitutionID = i1.InstitutionID
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement