Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Duplicate Problem

Author  Topic 

Ex
Posting Yak Master

166 Posts

Posted - 2006-03-30 : 17:41:00
Hi all,
I was given a access database trying to find the duplicates just want to make sure my queries are correct.

Ok so we have the columns

last Name, first Name , initial, title with name tblContacts

First i wanted to check for exact duplicates

used this query

select [last Name], [first Name],Initial, title, count(*)
from tblContacts
group by [last Name], [first Name],Initial, title
Having (count(*)> 1)

think that one is ok


next i wanted to check if one of the columns are out this is kinda where i am not sure i tried with just the title


select tb1.[last Name], tb1.[first Name],tb1.Initial, tb1.title
from tblContacts tb1 join tblContacts tb2 on
tb1.[last Name] = tb2.[last Name] and
tb1.[first Name] = tb2.[first Name] and
tb1.Initial = tb2.Initial
and tb1.title <> tb2.title
group by tb1.[last Name],tb1.[first Name],tb1.Initial, tb1.title


not exactly sure the correct sql for this, i am sure this query is not 100% though


------------------------------------------------------------------

sp2 for IE is FIREFOX !!

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2006-03-30 : 22:59:47
Ex,
You shouldn't need to join like this. Presumably this is the second step in the process which finds near hits. Why don't you just run the first query but leave out [Title]? This should give you similar results, but it will also include total matches. I'd be inclined to run them sequentially:
a: Number exact matches = 5
b: Number matches (excluding title) = 8 (which is 5 exact matches and 3 without title)
etc etc
It will also be easier to maintain than what you're trying to do.

HTH,

Tim
Go to Top of Page
   

- Advertisement -