Advertisement
Guest User

Untitled

a guest
Mar 15th, 2022
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.87 KB | None | 0 0
  1. SELECT aou.shortname
  2. FROM
  3. actor.org_unit aou
  4. JOIN action.hold_request ahr2 ON (ahr2.pickup_lib=aou.id)
  5. JOIN
  6. (
  7. SELECT ahr.id,COUNT(*)
  8. FROM
  9. action.hold_request ahr
  10. JOIN actor.usr au ON(au.id=ahr.usr)
  11. JOIN actor.usr_standing_penalty ausp ON(ausp.usr=au.id AND (ausp.stop_date IS NULL OR ausp.stop_date > NOW()))
  12. LEFT JOIN config.standing_penalty csp
  13. ON (
  14.     csp.id = ausp.standing_penalty AND
  15.     csp.block_list LIKE '%CAPTURE%' AND (
  16.         (csp.org_depth IS NULL AND ahr.pickup_lib = ausp.org_unit) OR
  17.         (csp.org_depth IS NOT NULL AND ahr.pickup_lib IN (
  18.         SELECT id FROM actor.org_unit_descendants(ausp.org_unit, csp.org_depth))
  19.         )
  20.     )
  21. )
  22. WHERE
  23. ahr.capture_time IS NULL AND
  24. ahr.cancel_time IS NULL AND
  25. csp.id IS NULL AND
  26. (ahr.expire_time IS NULL OR ahr.expire_time > NOW()) AND
  27. csp.id IS NULL
  28. GROUP BY 1
  29. HAVING COUNT(*) > 1
  30. ) bug_ids
  31. ON (bug_ids.id=ahr2.id)
  32. GROUP BY 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement