I have a single table with about 200,000 records. Each record refers to a single customer, but a customer may have one or more records. I need to identify which records belong to which customers and create a new field customer_id. So 1 or many records could end up with the same customer_id value. I can say that two or more records belong to the same customer if the values in fieldA match AND the values in fieldB match i.e. same customer if (rs1.fieldA = rs2.fieldA = rs[n].fieldA) AND (rs1.fieldB = rs2.fieldB = rs[n].fieldB)
For example, fields dob and ID are the fields I need to match to determine which records belong to which customers so
tool, dob, ID
mallet, 08/04/1959, AAAA
spanner, 08/04/1959, AAAA
hammer, 10/08/1965, AAAA
spade, 07/01/1955, AAAB
vice, 04/12/1980, AAAC
becomes
Cust ID, tool, dob, ID
00001, mallet, 08/04/1959, AAAA
00001, spanner, 08/04/1959, AAAA
00002, hammer, 10/08/1965, AAAA
00003, spade, 07/01/1955, AAAB
00004, vice, 04/12/1980, AAAC
I could write a nasty piece of code to do this but it would take for ever to run and I'm sure there is a wizzy piece of SQL that could do the job quicker! Any help would be greatly appreciated.