开发者

Show unique (differentiating) data in a duplicate search in Access?

开发者 https://www.devze.com 2023-03-12 10:20 出处:网络
I\'m trying to examine the unique fields of duplicate entries (the entries are duplicate in, say, 2 fields but unique in the other 4) - I have an access query to find duplicates but I can\'t for the l

I'm trying to examine the unique fields of duplicate entries (the entries are duplicate in, say, 2 fields but unique in the other 4) - I have an access query to find duplicates but I can't for the life of me figure out how to show only records that are duplicated in the given fields while still showing me the unique information about these records.

Ideas?

Update: here's my query. It's getting me a count of the repeated data, I want somehow to add in the unique data, fields like [AllEmail Name].[phone] amongst others.

SELECT 
      First([AllEmail Name].[email]) AS [email Field],
      First([AllEmail Name].[firstname]) AS [firstname Field],
      First([AllEmail Name].[lastname]) AS [lastname Field],
      Count([AllEmail Name].[email]) AS NumberOfDups,
      Count([AllEmail Name].allEmail.id) AS CountOfallEmail_id
FROM [AllEmail Name]
GROUP BY [AllEmail Name].[email], [AllEmail Name].[firstname], [AllEmail Name].[lastname]
HAVING (((Count([AllEmail Name].[email]))>1));

And another update, sample data:

Name   Email   Phone
John   j@q.net  2345
John   j@q.net  6789
John   j@me.net 2134
John   j@me.net 4444

would either return something like开发者_如何转开发

Name   Email  Dupes  Phone
John   j@q.net 2     2345
                     6789

or

John  j@me.net 2     2314
John  j@me.net 2     4444


Try to group it:

select t1.col1, t1.col2,
       t1.col3, t1.col4,
       count(*)                    -- number of identical rows based on cols
from   tbl t1
inner join tbl t2 on t2.col1 = t1.col1 -- same col1
                 and t2.col2 = t1.col2 -- same col2
                 and t2.id <> t1.id    -- but not the same pkey
group by t1.col1, t1.col2,
         t1.col3, t1.col4          -- merge when col3 and col4 are the same
0

精彩评论

暂无评论...
验证码 换一张
取 消