Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record numbering

Status
Not open for further replies.

HEMASUR

Technical User
Jun 3, 2005
28
US
I have a query that outputs duplicate records in a database, based on DOB and customer number. Due to data entry errors the same customer could have duplicate records, I need to print out this list out so that the names in the database can be fixed. I want to insert an index number to the customer number showing the number of records against the customer.

DOB ID LName FName
11/21/1910 33489 YURK LARRY
11/21/1910 33489 YARK LARRY
8/1/1912 46225 PALAZZOLO ANDY
8/1/1912 46225 PALAZZOLO ANDDY
12/15/1913 56769 SAUCEDO ERIC
12/15/1913 56769 SAUSEDO EIRC
12/15/1913 56769 SAUSEDO RIC

Printout
Index DOB ID LName FName
1 11/21/1910 33489 YURK LARRY
2 11/21/1910 33489 YARK LARRY
1 8/1/1912 46225 PALAZZOLO ANDY
2 8/1/1912 46225 PALAZZOLO ANDDY
1 12/15/1913 56769 SAUCEDO ERIC
2 12/15/1913 56769 SAUSEDO EIRC
3 12/15/1913 56769 SAUSEDO RIC

Is it possible to do this through a function, or a simple sql or vb statement.
Thanks to anyone who can help me.
 
Something like this (SQL code)?
SELECT Count(*) AS [Index], A.DOB, A.ID, A.LName, A.FName
FROM yourTable AS A INNER JOIN yourTable AS B ON A.DOB = B.DOB AND A.ID = B.ID AND A.LName & A.FName >= B.LName & B.FName
GROUP BY A.DOB, A.ID, A.LName, A.FName

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top