Unique values in two fields in query

  • Thread starter Thread starter Colin Hayes
  • Start date Start date
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
 
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
 
Back
Top