Duplicates query

Rough outline of script for finding duplicates.