[open-ils-commits] r11526 - branches/rel_1_4/Open-ILS/src/sql/Pg
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Dec 11 14:26:32 EST 2008
Author: miker
Date: 2008-12-11 14:26:29 -0500 (Thu, 11 Dec 2008)
New Revision: 11526
Modified:
branches/rel_1_4/Open-ILS/src/sql/Pg/extend-reporter.sql
Log:
logic fix to new bibs-by-holdings-change view
Modified: branches/rel_1_4/Open-ILS/src/sql/Pg/extend-reporter.sql
===================================================================
--- branches/rel_1_4/Open-ILS/src/sql/Pg/extend-reporter.sql 2008-12-11 19:26:08 UTC (rev 11525)
+++ branches/rel_1_4/Open-ILS/src/sql/Pg/extend-reporter.sql 2008-12-11 19:26:29 UTC (rev 11526)
@@ -33,6 +33,28 @@
GROUP BY cp.id;
CREATE OR REPLACE VIEW extend_reporter.global_bibs_by_holding_update AS
+ SELECT DISTINCT ON (id) id, holding_update, update_type
+ FROM (SELECT b.id,
+ LAST(cp.create_date) AS holding_update,
+ 'add' 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' 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 id, holding_update;
+
SELECT id, LAST(holding_update) AS holding_update, update_type
FROM (SELECT b.id,
LAST(cp.create_date) AS holding_update,
More information about the open-ils-commits
mailing list