UBS Interview Question

SQL queries of finding duplicates