...
- Note that you must find the MAX row number from the records_lb table, and join the records_lb table to the marc__t table on marc__t.srs_id = records_lb.matched_id. This is a different join than the one described below this section.previously
- It is not necessary to specify state = 'ACTUAL' in the Where section of the query, since that condition no longer limits the results to the correct record (an instance can have multiple srs_id's that are all "ACTUAL")
SELECT
sm.instance_hrid,
sm.content AS lc_classification,
SUBSTRING (sm.content,'[A-Za-z]{0,}') as lc_class,
TRIM (TRAILING '.' from SUBSTRING (sm.content, '\d{1,}\.{0,}\d{0,}')) AS lc_class_number,
MAX (records_lb.__id)
FROM folio_source_record.marc__t AS sm
INNER JOIN folio_source_record.records_lb
ON sm.srs_id = records_lb.matched_id
WHERE sm.field = '050'
AND sm.sf = 'a'
AND sm.ord = 1
GROUP BY sm.instance_hrid, sm.content
------------------------------------------------------------------------------------------------------------------------------------
...