Unique values in two fields in query


C

Colin Hayes

Hi All

In my db I have some duplicated values in two fields.

I need to make my query match these and only show records which have no
duplication in these fields. How should I amend my query to do this?

The Unique Records / Unique Values switches seem to affect the whole
query and not just the two fields I want to match.

Grateful for any advice.



Best Wishes
 
Ad

Advertisements

D

Douglas J Steele

Create a subquery that returns those combinations that appear only once:

SELECT Field1, Field2
FROM MyTable
GROUP BY Field1, Field2
HAVING Count(*) = 1

Join your table to that subquery:

SELECT Id, Field1, Field2, Field3
FROM MyTable
INNER JOIN
(SELECT Field1, Field2
FROM MyTable
GROUP BY Field1, Field2
HAVING Count(*) = 1) As Subq
ON MyTable.Field1 = Subq.Field1
AND MyTable.Field2 = Subq.Field2

"Colin Hayes" wrote in message

Hi All

In my db I have some duplicated values in two fields.

I need to make my query match these and only show records which have no
duplication in these fields. How should I amend my query to do this?

The Unique Records / Unique Values switches seem to affect the whole
query and not just the two fields I want to match.

Grateful for any advice.



Best Wishes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top