how to find duplicate records in sql with condition