Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Re: Query
Divers
Thread ID:
00494301
Message ID:
00494445
Vues:
15
Hi Mike,
>This is a really basic query which makes use of the GROUP BY and HAVING clauses:
>
>SELECT lastname, COUNT(*)
>FROM persontable
>GROUP BY lastname
>HAVING COUNT(*) > 1
>
>This query will return all the last names that are duplicated and the number of times their duplicated. If you want to return the entire name, you'll need to use the above query as a subquery:
>
>SELECT firstname, lastname
>FROM persontable
>WHERE lastname IN (
> SELECT lastname, COUNT(*)
> FROM persontable
> GROUP BY lastname
> HAVING COUNT(*) > 1)
>

Close! I can't believe I caught you. <VBG>

The subquery must return one value. i.e. eliminate the COUNT(*) from the select list. Then it works as you describe.
Bill Armbrecht
VFP MCP
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform