Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select minimum
Message
 
 
À
11/06/2007 17:03:13
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
01232093
Message ID:
01232094
Vues:
13
>Suppose you have issued a sql-select which returns several records containing the fields COST and SITE among others. Then suppose you want to select from this result the minimum COST and its corresponding SITE. As in:
>
>select min(cost), site from crs1
>
>
>This produces an error Group clause invalid. How should this second select be structured?
>
>
>Thanks for your suggestions.
select crs1.* from crs1 inner join ;
(select site, MIN(cost) as MinCost from crs1 group by 1) crs2 on ;
crs1.site = crs2.site and crs1.Cost = crs2.MinCost
Note, that this will return several records if you have several identical Min cost.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform