Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Retrieving duplicate records
Message
 
À
29/01/2001 12:16:52
Scott Schuman
Innovative Resource Group
Milwaukee, Wisconsin, États-Unis
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00469792
Message ID:
00469939
Vues:
10
>How can I write a SQL statement that only retrns records where there are duplicate records in a given field. For example: Return all of the user records in states where there are more than one users.
>
>Scott Schuman
>Innovative Resource Group, Inc.
-----------------------------------------------------------------

If I undestand correctly, you wish to return records that match some criteria that return more than one record. This will return all users who live in states that have more than one user.

SELECT UserName, UserAddress, ...
FROM mytable
WHERE State IN (SELECT State, COUNT(UserID)
FROM mytable
GROUP BY State
HAVING COUNT(UserID) > 1)

Please let me know, if I missed the point completetly.
Aristotle
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform