Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Deleting Duplicate Records In Table
Message
 
 
À
12/04/2013 10:06:09
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01570796
Message ID:
01570801
Vues:
62
>Using the following code I could Get the number of counts for Duplicate records. But How do I delete the Duplicate entries, i.e I just want to keep the one single entry for my account Number, Preferebly the last one.
>
>
>SELECT Accountno As Account_No,COUNT( * ) AS DupCount;
>  FROM New_master ;
>  INTO CURSOR Duplicates ;
>  GROUP BY Accountno ;
>  HAVING DupCount > 1 
>
>
>I tried Select * from New_master UNION Select * from New_master . But It didn't worked.

From the top of my head
delete NM from New_Master NM ;
where exists (select 1 from (SELECT Accountno As Account_No,COUNT( * ) AS DupCount, MAX(AccountDate) as LastDate ;
  FROM New_master ;
  GROUP BY Accountno ;
  HAVING DupCount > 1)  X where X.Account_No = NM.AccountNo and NM.AccountDate < X.LastDate)
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform