Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sql to find duplicates
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00811118
Message ID:
00811128
Vues:
10
>>>Hi,
>>>Can someone help me with the SQL to find all duplicates in a field?
>>>Thanks,
>>>Allen
>>
select KeyFld, count(*) as CntDups from TestDups group by 1 ;
>>     having CntDups > 1 ;
>>     into cursor curDupes
>>
>
>Sorry but I did get it...
>Keyfld for me is lineitems_id
>TestDups table is lineitems
>What's CntDups... a variable?
>
>Allen



CntDups becomes a calculated field in your query result (cursor).
Basically you are saying to group by "lineitems_id" and count how many show up. Then disregard the ones that show up only once and show only 2 or more instances ("having CntDups > 1").
select lineitems_id, count(*) as CntDups ;
from lineitems ;
group by 1 ;
having CntDups > 1 ;
into cursor curDupes
Clearer?


Alex Feldstein, MCP, Microsoft MVP
VFP Tips: English - Spanish
Website - Blog - Photo Gallery


"Once again, we come to the Holiday Season, a deeply religious time that each of us observes, in his own way, by going to the mall of his choice." -- Dave Barry
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform