*** This version of Confluence is for testing only and contains a copy of content from June 29th 2026. No changes will be preserved. ***
...
It is impossible to account for every variation of page number entry in your query
Basic Code Template for Page Numbers
Here is some code to serve as a basic template for adding data showing the number of pages in the physical items you have selected in your query.
-- MARC 300 subfield a rows (can have multiple per instance)
number_of_pages_raw AS (
SELECT
m.instance_hrid,
m.content AS physical_description_300a,
-- numeric page count
CASE
WHEN substring(m.content from '\d{1,4}') IS NOT NULL
AND substring(m.content from '\d{1,4}')::int <= 3000
THEN substring(m.content from '\d{1,4}')::int
ELSE NULL
END AS page_count_estimate
FROM folio_source_record.marc__t AS m
LEFT JOIN folio_source_record.records_lb AS rec
ON m.instance_id = rec.external_id
WHERE m.field = '300'
AND m.sf = 'a'
AND rec.state = 'ACTUAL'
),
-- group to one row per instance_hrid
number_of_pages AS (
SELECT
instance_hrid,
MIN(physical_description_300a) AS physical_description_300a,
MIN(page_count_estimate) AS page_count_estimate
FROM number_of_pages_raw
GROUP BY instance_hrid
),
