Skip to content

Instantly share code, notes, and snippets.

@rayvoelker
Created October 17, 2016 17:46
Show Gist options
  • Save rayvoelker/8a3f7c4250e0eb79aef6006144557cac to your computer and use it in GitHub Desktop.
Save rayvoelker/8a3f7c4250e0eb79aef6006144557cac to your computer and use it in GitHub Desktop.
SELECT
'p' || r.record_num || 'a' as patron_record_num,
v.field_content,
b.index_entry as barcode,
n.index_entry as patron_name_norm
FROM
sierra_view.record_metadata as r
JOIN
sierra_view.varfield as v
ON
v.record_id = r.id
-- get patron barcode
LEFT OUTER JOIN
sierra_view.phrase_entry AS b
ON
(b.record_id = r.id) AND (b.index_tag = 'b')
-- get normalized patron name
LEFT OUTER JOIN
sierra_view.phrase_entry AS n
ON
(n.record_id = r.id) AND (n.index_tag = 'n')
WHERE
r.record_type_code = 'p'
AND v.varfield_type_code = 'z'
AND v.field_content IN
(
'rvoelker1@udayton.edu'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment