[FONT="]Hello fellow Access programmers and best wishes![/FONT]
[FONT="]I have built quite a lot of queries in the past, but I'm not too sure how to attack this one exactly.[/FONT]
[FONT="]I'm looking to have one central table containing customer data. Until now, instead of using such a central table containing all data, a new record has been created for every exchange with that customer, including all the data that he or she provided at that time, every time again.[/FONT]
[FONT="]I've already created a query to extract all the customer data from those tables. However, there are many duplicates in the table resulting from this query (every customer that has several exchanges will be there several times). Unfortunately the classical duplicate removal techniques won't work if you take everything I'm looking for into account.[/FONT]
[FONT="]So basically I have now one table named Table1 with the following fields:[/FONT]
[FONT="]
[FONT="]Examples of two records:[/FONT]
[FONT="]
[FONT="]One can assume that all records with the same Name AND Firstname AND (Postalcode OR Mail OR Phone OR Phone2) are referring to the same customer. Phone = Phone2 should also be accepted in the last part.[/FONT]
[FONT="]A basic approach could be to group data and use Max or Min to pick only one (random) value for every field where the different values are not identical. However, I'm looking to go a lot further. I would like to obtain the following Table2:[/FONT]
[FONT="]
[FONT="]The idea behind this table is that no data gets lost: if there are several values for the same field (Postalcode, Address etc) for the same customer, the extra values should be stored in the field Address2, Address3 etc. The field Lastcontact (which contains a date) determines which field will be used (the most recent contact into Address, the next most recent into Address2 etc). So unfortunately "simply" grouping data doesn't help me. [/FONT]
[FONT="]Example of how I would like the two above-mentioned records to be merged:[/FONT]
[FONT="]
[FONT="]I've tried quite a lot of things, but haven't found a solution that really does what I need. Now I'm thinking of using an awful lot of IIfs and Dlookups to make this Table2, but I hope that there is another, more efficient way. I'll take any suggestion that I can develop myself, so I'm not necessarily asking for a complete query. [/FONT]
[FONT="]Many thanks![/FONT]
[FONT="]I have built quite a lot of queries in the past, but I'm not too sure how to attack this one exactly.[/FONT]
[FONT="]I'm looking to have one central table containing customer data. Until now, instead of using such a central table containing all data, a new record has been created for every exchange with that customer, including all the data that he or she provided at that time, every time again.[/FONT]
[FONT="]I've already created a query to extract all the customer data from those tables. However, there are many duplicates in the table resulting from this query (every customer that has several exchanges will be there several times). Unfortunately the classical duplicate removal techniques won't work if you take everything I'm looking for into account.[/FONT]
[FONT="]So basically I have now one table named Table1 with the following fields:[/FONT]
[FONT="]
[/FONT]Name
Firstname
Address
Postalcode
Town
Phone
Phone2 (all text fields)
Lastcontact (date)
[FONT="]Examples of two records:[/FONT]
[FONT="]
[/FONT]Smith - John - Mulholland Drive 1 - 1000 - Washington - johnsmith (at) gmail.com - 04854527 - 157852158 - 01/01/2012
Smith - John - Fifth Avenue 6 - 2000 - New York - johnsmith (at) gmail.com - 02300155 - (Null) - 31/12/2011
[FONT="]One can assume that all records with the same Name AND Firstname AND (Postalcode OR Mail OR Phone OR Phone2) are referring to the same customer. Phone = Phone2 should also be accepted in the last part.[/FONT]
[FONT="]A basic approach could be to group data and use Max or Min to pick only one (random) value for every field where the different values are not identical. However, I'm looking to go a lot further. I would like to obtain the following Table2:[/FONT]
[FONT="]
[/FONT]AutoID
Name
Firstname
Address
Address2
Address3
Postalcode
Postalcode2
Postalcode3
Town
Town2
Town3
Mail2
Mail3
Phone
Phone2
Phone3
[FONT="]The idea behind this table is that no data gets lost: if there are several values for the same field (Postalcode, Address etc) for the same customer, the extra values should be stored in the field Address2, Address3 etc. The field Lastcontact (which contains a date) determines which field will be used (the most recent contact into Address, the next most recent into Address2 etc). So unfortunately "simply" grouping data doesn't help me. [/FONT]
[FONT="]Example of how I would like the two above-mentioned records to be merged:[/FONT]
[FONT="]
[/FONT](AutoID) - Smith - John - Mulholland Drive 1 - Fifth Avenue 6 - (Null) - 1000 - 2000 - (Null) - Washington - New York - (Null) - johnsmith (at) gmail.com - (Null) - (Null) - 04854527 - 157852158 - 02300155
[FONT="]I've tried quite a lot of things, but haven't found a solution that really does what I need. Now I'm thinking of using an awful lot of IIfs and Dlookups to make this Table2, but I hope that there is another, more efficient way. I'll take any suggestion that I can develop myself, so I'm not necessarily asking for a complete query. [/FONT]
[FONT="]Many thanks![/FONT]