Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Aggregate functions and other fields
Message
From
14/02/2006 11:21:44
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Novell 5.x
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01096186
Message ID:
01096193
Views:
15
>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform