Skip to content

Instantly share code, notes, and snippets.

@cl4rk3
Last active August 29, 2015 14:23
Show Gist options
  • Save cl4rk3/6b1d63f2acb0956fa127 to your computer and use it in GitHub Desktop.
Save cl4rk3/6b1d63f2acb0956fa127 to your computer and use it in GitHub Desktop.
Cleanup Multiple MAVIS records per AAPB GUID
-- Shows that there are 1819 titles with duplicated GUIDS
SELECT COUNT(title_no)
FROM aims.TITLE_OTHER_ID_FQV
WHERE identifier IN
(SELECT identifier
FROM
(SELECT identifier,
COUNT(title_no) AS tcount
FROM aims.TITLE_OTHER_ID_FQV
WHERE IDENTIFIER_TYPE = 'AMARCGUID'
GROUP BY identifier
ORDER BY tcount DESC
)
WHERE tcount >1
);
-- gives the list of affected titles (titles that are records with shared AAPB GUIDs)
select unique(title_no) from aims.ITEM where TITLE_NO in (SELECT title_no
FROM aims.TITLE_OTHER_ID_FQV
WHERE identifier IN
(SELECT identifier
FROM
(SELECT identifier,
COUNT(title_no) AS tcount
FROM aims.TITLE_OTHER_ID_FQV
WHERE IDENTIFIER_TYPE = 'AMARCGUID'
GROUP BY identifier
ORDER BY tcount DESC
)
WHERE tcount >1
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment