I am trying to create a query that will return all non-dual (unique) records in a table. The request will require several fields to determine duplicate entries.
For example, if the table has the following fields; PKID, ClientID, Name, AcctNo, OrderDate, Charge, I would like to use the AcctNo, OrderDate and Charge fields to search for unique records.
Table
PKID-----ClientID-----Name-----AcctNo-----OrderDate-----Charge 1 JX100 John 12345 9/9/2010 $100.00 2 JX220 Mark 55567 9/9/2010 $23.00 3 JX690 Matt 89899 9/9/2010 $218.00 4 JX100 John 12345 9/9/2010 $100.00
The result of the request should be:
PKID-----ClientID-----Name-----AcctNo-----OrderDate-----Charge 2 JX220 Mark 55567 9/9/2010 $23.00 3 JX690 Matt 89899 9/9/2010 $218.00
I tried using SELECT DISTINCT, but this does not work because it saves one of the duplicate records as a result. I also tried using HAVING COUNT = 1, but it returns all records.
Thanks for the help.
sql duplicates
nth
source share