Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT aou.shortname
- FROM
- actor.org_unit aou
- JOIN action.hold_request ahr2 ON (ahr2.pickup_lib=aou.id)
- JOIN
- (
- SELECT ahr.id,COUNT(*)
- FROM
- action.hold_request ahr
- JOIN actor.usr au ON(au.id=ahr.usr)
- JOIN actor.usr_standing_penalty ausp ON(ausp.usr=au.id AND (ausp.stop_date IS NULL OR ausp.stop_date > NOW()))
- LEFT JOIN config.standing_penalty csp
- ON (
- csp.id = ausp.standing_penalty AND
- csp.block_list LIKE '%CAPTURE%' AND (
- (csp.org_depth IS NULL AND ahr.pickup_lib = ausp.org_unit) OR
- (csp.org_depth IS NOT NULL AND ahr.pickup_lib IN (
- SELECT id FROM actor.org_unit_descendants(ausp.org_unit, csp.org_depth))
- )
- )
- )
- WHERE
- ahr.capture_time IS NULL AND
- ahr.cancel_time IS NULL AND
- csp.id IS NULL AND
- (ahr.expire_time IS NULL OR ahr.expire_time > NOW()) AND
- csp.id IS NULL
- GROUP BY 1
- HAVING COUNT(*) > 1
- ) bug_ids
- ON (bug_ids.id=ahr2.id)
- GROUP BY 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement