Skip to content

Instantly share code, notes, and snippets.

@sandbergja
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandbergja/32262201df345f7b5cca to your computer and use it in GitHub Desktop.
Save sandbergja/32262201df345f7b5cca to your computer and use it in GitHub Desktop.
series problem (490 w/o 830)
SELECT DISTINCT b.id as tcn, ou.name as library, cn.label as call_number, c.barcode, xpath('//m:datafield[@tag="245"]/m:subfield[@code="a"]/text()', b.marc::xml, ARRAY[ARRAY['m','http://www.loc.gov/MARC21/slim']])::VARCHAR as title
FROM biblio.record_entry b
INNER JOIN asset.call_number cn ON cn.record=b.id
INNER JOIN asset.copy c ON c.call_number=cn.id
INNER JOIN actor.org_unit ou on ou.id=c.circ_lib
WHERE b.deleted=FALSE
AND b.id != -1
AND xpath_exists('//m:datafield[@tag="490" and @ind1="1"]', b.marc::xml, ARRAY[ARRAY['m','http://www.loc.gov/MARC21/slim']])
AND marc NOT LIKE '%tag="800%'
AND marc NOT LIKE '%tag="810%'
AND marc NOT LIKE '%tag="811%'
AND marc NOT LIKE '%tag="830%'
AND c.circ_lib=7
ORDER BY library;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment