extend_reporter.global_bibs_by_holding_update (view)
|
This is a database view, not a base table. It has no triggers, indexes, or FK constraints of its own. Querying this view may be more efficient than joining the underlying tables directly. |
Columns
| Column | Type | Nullable | Notes |
|---|---|---|---|
id |
|
Yes |
|
holding_update |
|
Yes |
|
update_type |
|
Yes |
View Definition
SELECT DISTINCT ON (x.id) x.id,
x.holding_update,
x.update_type
FROM ( SELECT b.id,
last(cp.create_date) AS holding_update,
'add'::text AS update_type
FROM biblio.record_entry b
JOIN asset.call_number cn ON cn.record = b.id
JOIN asset.copy cp ON cp.call_number = cn.id
WHERE NOT cp.deleted AND b.id > 0
GROUP BY b.id
UNION
SELECT b.id,
last(cp.edit_date) AS holding_update,
'delete'::text AS update_type
FROM biblio.record_entry b
JOIN asset.call_number cn ON cn.record = b.id
JOIN asset.copy cp ON cp.call_number = cn.id
WHERE cp.deleted AND b.id > 0
GROUP BY b.id) x
ORDER BY x.id, x.holding_update;