Last active
August 29, 2015 14:23
-
-
Save cl4rk3/6b1d63f2acb0956fa127 to your computer and use it in GitHub Desktop.
Cleanup Multiple MAVIS records per AAPB GUID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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