devxlogo

Reporting duplicates

Reporting duplicates

Question:
I am having trouble figuring out how to make a report dealing with duplicates. I need to selcet from a table only instances where the first 10 characters of two columns match. For example, I combine the first and last name columns with (||), then I need to take the first 10 letters of the combined column and compare them to the rest of the table to match potential duplicates.

Answer:
Try this and see if it gets you there, or at least gets you started. Play with the length of the second argument in the substring function to see how it changes the columns returned.

create table #dummy (mushedupname Varchar(100))insert #dummy select au_lname+au_fname from authors as mushedupnameselect a.mushedupname, b.mushedupname from #dummy a,  #dummy bwhere substring(a.mushedupname,1,5) = substring(b.mushedupname,1,5)

See also  How to Create and Deploy QR Codes Online: A Comprehensive Guide
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist