Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. select distinct a.AuditID
  2. , i.InstitutionID
  3. , 0
  4. , 1
  5. , 0
  6. from tAudit a (index XIE4tAudit )
  7. , hInstitution i (index XPKhInstitution )
  8. , tInstRelation ir (index XIE1tInstRelation)
  9. where a.InDateTime >= dateadd(dd,-1,getdate())
  10. and a.Action in (1,2)
  11. and a.ObjectName = "tInstitution"
  12. and a.ObjectReference = 1
  13. and i.HistoryHeaderID = a.AuditID
  14. and i.PropDealPart = 0
  15. and i.MainMember = 1
  16. and ir.InstRelTypeID = 10000000010
  17. and ir.InstParentID = 10000000003
  18. and ir.InstChildID = i.InstitutionID
  19. and ir.DocCloseFlag = 0
  20. and ir.DateClose = '19000101'
  21. and a.InDateTime = (select min(a1.InDateTime)
  22. from tAudit a1 (index XIE4tAudit )
  23. , hInstitution i1 (index XPKhInstitution )
  24. , tInstRelation ir1 (index XPKtInstRelation)
  25. where a1.InDateTime >= dateadd(dd,-1,getdate())
  26. and a1.Action in (1,2)
  27. and a1.ObjectName = "tInstitution"
  28. and a1.ObjectReference = 1
  29. and i1.HistoryHeaderID = a1.AuditID
  30. and i.InstitutionID = i1.InstitutionID
  31. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement