AlphaPress Publishing
P.O. Box 5942 Albany, NY 12205
Tel: 518-250-3890

Click to buy this book from Amazon

Section Menu 


Pindaro is now working on a comprehensive book on SQL Server 2014.  For any comments you can email the author at




Find duplicate records in a table based on the values of one field

To contact the author click here

This article is from the book "Access 2007 Pure SQL

To download the sample database click here


Find duplicate records in a table based on the values of one field

Find duplicate customer orders based on the value of the orderID


In this example, we are looking for records in the tbls_Orders table that have the same value for the OrderID field.  In addition, we use the count(*) function to  calculate the number of instances of duplicate records.  We can use the code below to look for duplicate values for any field.  We will just replace the OrderID field with the field on which we want to search for duplicate values.  Remember that this example will give us duplicate field values and not necessarily duplicate records.  Though the OrderID values are the same, the rest of the fields in the returned records might have different values.  Still, it is very useful to know how to search for duplicate values on one field.  As you can see from the result set, two records have null values for the OrderID.  In addition, there are two instances of duplicate records for OrderIDs with values 8, 45, 254, and 820.  Finally, the OrderId with value 993 appears in three records in the table. 


SELECT OrderID, Count(*) AS NumberofDuplicates

FROM tbls_Orders


HAVING count(*)>1