Board index » delphi » Duplicated records

Duplicated records


2006-09-26 09:08:09 AM
delphi137
I can have duplicated customers, but I want to show them to user to be fixed
1 - Juliana Pegoraro - Rua Visconde de Nacar, 1505 - Curitiba - Pr -
14/03/98
5 - Muliana Segoraro - Rua Visconde de Nacar, 1505 - Curitiba - Pr -
25/12/00
9 - Juliana Pegoraro - Rua Visconde de Nacar, 1505 - Curitiba - Pr -
14/03/98
now, I want to list all records which are equals. I cannot use a group by
because I need the ID and the ID will never be the same, so I did this
select and it works fine but does exist another which is better ?
select ID, Name, Address, City, State, AccountDate where Nome = 'Juliana
Pegoraro' and ID <>P.ID and
((Address = P.Address ) or ((Address is Null) and (P.Address is Null))) and
((City= P.City) or ((Cityis Null) and (P.Cityis Null))) and
((State = P.State) or ((State is Null) and (P.State is Null))) and
((AccountDate = P.AccountDate) or ((AccountDate is Null) and (P.AccountDate
is Null)))
and a better one, how to list all records which have another record exacly
equal to it ? this example I am comparing just with one specific name.
Marcos Pegoraro
 
 

Re:Duplicated records

I can have duplicated customers, but I want to show them to user to be fixed
1 - Juliana Pegoraro - Rua Visconde de Nacar, 1505 - Curitiba - Pr -
14/03/98
5 - Muliana Segoraro - Rua Visconde de Nacar, 1505 - Curitiba - Pr -
25/12/00
9 - Juliana Pegoraro - Rua Visconde de Nacar, 1505 - Curitiba - Pr -
14/03/98
now, I want to list all records which are equals. I cannot use a group by
because I need the ID and the ID will never be the same, so I did this
select and it works fine but does exist another which is better ?
select ID, Name, Address, City, State, AccountDate from Customers P where
Nome = 'Juliana
Pegoraro' and exists(select ID from Customers ID ID <>P.ID and
((Address = P.Address ) or ((Address is Null) and (P.Address is Null))) and
((City= P.City) or ((Cityis Null) and (P.Cityis Null))) and
((State = P.State) or ((State is Null) and (P.State is Null))) and
((AccountDate = P.AccountDate) or ((AccountDate is Null) and (P.AccountDate
is Null)))
and a better one, how to list all records which have another record exacly
equal to it ? this example I am comparing just with one specific name.
Marcos Pegoraro