Advertisement
chrissharp123

Untitled

Aug 31st, 2017
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT  DISTINCT(record),
  2.         COALESCE(n72.quality, 0) + COALESCE(n73.quality, 0) + COALESCE(n74.quality, 0) + COALESCE(n75.quality, 0) + COALESCE(n76.quality, 0) + COALESCE(n77.quality, 0) AS quality
  3. FROM    
  4.         (SELECT *, 2 AS quality FROM metabib.full_rec mfr WHERE mfr.tag = '020' AND mfr.subfield = 'a' AND (LOWER(mfr.value) LIKE '9781492629887%' OR LOWER(mfr.value) LIKE '149262988x%')) n72
  5.         FULL OUTER JOIN (SELECT *, 2 AS quality FROM metabib.full_rec mfr WHERE mfr.tag = '022' AND mfr.subfield = 'a' AND (LOWER(mfr.value) LIKE NULL)) n73 USING (record)
  6.         FULL OUTER JOIN (SELECT *, 2 AS quality FROM metabib.full_rec mfr WHERE mfr.tag = '024' AND mfr.subfield = 'a' AND (LOWER(mfr.value) LIKE NULL)) n74 USING (record)
  7.         FULL OUTER JOIN (SELECT *, 2 AS quality FROM metabib.full_rec mfr WHERE mfr.tag = '028' AND mfr.subfield = 'a' AND (mfr.value = NULL)) n75 USING (record)
  8.         FULL OUTER JOIN (SELECT *, id AS record, 16 AS quality FROM metabib.record_attr_flat mraf WHERE mraf.attr = 'bib_level' AND mraf.value = $2->'bib_level') n76 USING (record)
  9.         FULL OUTER JOIN (SELECT *, id AS record, 16 AS quality FROM metabib.record_attr_flat mraf WHERE mraf.attr = 'item_type' AND mraf.value = $2->'item_type') n77 USING (record)
  10.         JOIN biblio.record_entry bre ON (bre.id = record)
  11. WHERE (((n72.id IS NOT NULL) OR (n73.id IS NOT NULL) OR (n74.id IS NOT NULL) OR (n75.id IS NOT NULL)) AND (n76.id IS NOT NULL) AND (n77.id IS NOT NULL)) AND not bre.deleted
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement