alexa

Eliminating duplicates with specific conditions in SQL ?

Eliminating duplicates with specific conditions in SQL ?

This will do the trick (if the table is duplicates). If you want to delete the rows:

 delete from duplicates d 
where first_name is null and last_name is null 
and 1 < (select count(*) from duplicates where phone_number = d.phone_number); 

If you just want to get the new relation:

 select * from duplicates d 
where not (first_name is null and last_name is null 
and 1 < (select count(*) from duplicates where phone_number = d.phone_number));

407 0
7

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online

Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry