my $select = <<" SQL";
WITH
t_field AS (SELECT field FROM config.display_field_map WHERE name = 'title'),
- a_field AS (SELECT field FROM config.display_field_map WHERE name = 'author')
+ a_field AS (SELECT field FROM config.display_field_map WHERE name = 'author'),
+ s_field AS (SELECT field FROM config.display_field_map WHERE name = 'series_title')
SELECT h.id, h.request_time, h.capture_time, h.fulfillment_time, h.checkin_time,
h.return_time, h.prev_check_time, h.expire_time, h.cancel_time, h.cancel_cause,
h.cancel_note, h.target, h.current_copy, h.fulfillment_staff, h.fulfillment_lib,
t.value AS title,
a.value AS author,
+ s.value AS series_title,
acpl.id AS acpl_id, acpl.name AS acpl_name, acpl.owning_lib AS acpl_owning_lib, acpl.holdable AS acpl_holdable,
acpl.hold_verify AS acpl_hold_verify, acpl.opac_visible AS acpl_opac_visible, acpl.circulate AS acpl_circulate,
JOIN actor.org_unit pl ON (h.pickup_lib = pl.id)
JOIN t_field ON TRUE
JOIN a_field ON TRUE
+ JOIN s_field ON TRUE
LEFT JOIN action.hold_request_cancel_cause cc ON (h.cancel_cause = cc.id)
LEFT JOIN biblio.monograph_part p ON (h.hold_type = 'P' AND p.id = h.target)
LEFT JOIN serial.issuance siss ON (h.hold_type = 'I' AND siss.id = h.target)
LEFT JOIN LATERAL (SELECT COUNT(*), MAX(notify_time) FROM action.hold_notification WHERE h.id = hold) n ON TRUE
LEFT JOIN LATERAL (SELECT FIRST(value) AS value FROM metabib.display_entry WHERE source = r.bib_record AND field = t_field.field) t ON TRUE
LEFT JOIN LATERAL (SELECT FIRST(value) AS value FROM metabib.display_entry WHERE source = r.bib_record AND field = a_field.field) a ON TRUE
+ LEFT JOIN LATERAL (SELECT FIRST(value) AS value FROM metabib.display_entry WHERE source = r.bib_record AND field = s_field.field) s ON TRUE
LEFT JOIN LATERAL actor.org_unit_ancestor_setting('circ.holds.default_estimated_wait_interval',u.home_ou) AS default_estimated_wait_interval ON TRUE
LEFT JOIN LATERAL actor.org_unit_ancestor_setting('circ.holds.min_estimated_wait_interval',u.home_ou) AS min_estimated_wait_interval ON TRUE
LEFT JOIN LATERAL actor.org_unit_ancestor_setting('circ.hold_shelf_status_delay',h.pickup_lib) AS hold_wait_time ON TRUE,