Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Help?
Message
De
19/08/1997 12:20:23
 
 
À
17/08/1997 01:57:49
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00044834
Message ID:
00045582
Vues:
34
>>
>> Can someone help me with the SQL to find duplicate records in a table where
>> a duplicate is considered two out of five matching fields? I thought:
>> SELECT * ;
>> FROM table;
>> WHERE keyfield IN ;
>> (SELECT keyfield ;
>> FROM tablel ;
>> GROUP BY keyfield, field2;
>> HAVING count(*) > 1)
>> would do the trick, but it doesn't work. TIA
>>
>> Erik
>
> SELECT * ;
> FROM table;
> WHERE keyfield IN ;
> (SELECT keyfield, count(*) as cnt ;
> FROM tablel ;
> GROUP BY keyfield, field2;
> HAVING cnt > 1)
>
>....but then, I've never done this, to have two fields in a subquery used
>for Where ... in ( ). Maybe it could give you some extra records, if
>keyfield is numeric and equal to number of appearances in table1.
>Really, what does SQL do in this case? Does it compare table.keyfield
>with subquery.keyfield only, or compares it with subquery.cnt too?

Arnon- your suggested code gave an error from the command window. I am not sure I see how this code effectively differs from the query that I submitted originally? I think that you were just explicitly naming the count and then referring to it in the HAVING clause. I don't know why it spit it back though. Anyone else care to take a stab at this?

Erik Moore
Erik Moore
Clientelligence
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform