Skip to content

Instantly share code, notes, and snippets.

@pmgreen
Created September 15, 2014 21:13
Show Gist options
  • Select an option

  • Save pmgreen/519ce8ed009c58a472bc to your computer and use it in GitHub Desktop.

Select an option

Save pmgreen/519ce8ed009c58a472bc to your computer and use it in GitHub Desktop.
Get a random sample of n records per Voyager location
/* Relates to Ex Libris' Voyager ILS. Used in Toad for Oracle Freeware and SQL Developer (not MS Access) */
SELECT * FROM (
SELECT b.BIB_ID, m.MFHD_ID, m.LOCATION_ID, ROW_NUMBER()
OVER (
PARTITION BY m.LOCATION_ID ORDER BY m.LOCATION_ID
) SampleCount FROM BIB_TEXT b LEFT JOIN BIB_MFHD bm ON b.BIB_ID = bm.BIB_ID
LEFT JOIN MFHD_MASTER m ON bm.MFHD_ID = m.MFHD_ID
WHERE m.LOCATION_ID IN
(
'1', '6', '7'
))
WHERE SampleCount <= n;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment