Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Aggregate functions and other fields
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Novell 5.x
Database:
Visual FoxPro
Divers
Thread ID:
01096186
Message ID:
01096193
Vues:
14
>When I do a query ... lets say, "SELECT MAX(COST) AS COST, INVNO FROM INVOICES" ... what do I know about the value of INVNO in the result set? ENGINEBEHAVIOR is 70. In all the testing I have done, it always SEEMS to return the value from the record containing the MAX() value. However, I don't KNOW any specifics about the code that performs the fetch, so I don't know whether this is a reliable observation or not.
>
>Does anyone have any specific info regarding this?
>
>Regards
>
>Art

It depends how this SELECT continues, if you have:
SELECT MAX(COST) AS COST, INVNO FROM INVOICES GROUP BY InvNo
then you always will get MAX(cost) for some specific invoice #. But if you didn't have such grouping you can't expect always to get right record, sometimes you'll get InvNo where the MAX(Cost) is, sometimes you will not, so you can't rely on this. Better change this to:
SELECT COST, INVNO FROM INVOICES WHERE Cost = (SELECT MAX(Cost) FROM Invoices) ...
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform