Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SELECTing MAX()
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00452686
Message ID:
00452699
Vues:
27
>What would be the best way to do this in a SELECT statment?
>I have a table with scores. Each person may have more than one score but I need to select only the highest for EACH person.
>
>I am not sure how to do it in a subquery. I tried something like this but of course is not good:
>SELECT * FROM myCur WHERE id = id;
>AND score IN ;
> (SELECT MAX(score) FROM myCur)
>
>thanks in advance

You don't need a subquery to do this, but don't select all the fields unless you want all the fields except the score in the GROUP BY expression.
Select Name, Max(Score) ;
   from myCur ;
   where Id = Id ;
   into cursor whatever ;
   group by Name
If you want something besides the name and score in the result, add that field to both the list of fields you're selecting and the Group By clause.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform