[V4WS 1.11] Best way to find a record with the minimum value of a certain field?

Steven Ronald stevenrt39 at yahoo.com.au
Mon Nov 27 11:50:54 CST 2006


Ruslan,

I want to find the record in a table with the minimum
value of a certain field, then retrieve values of
other fields for that record and possibly update them.

I can do this two ways:

cursor=select MIN(foo) from table
minfoo=valgetfield(cursor,1)
cursor=select frac1,frac2,frac3 from table where
foo=minfoo
frac1=valgetfield(cursor,1) etc ...


OR

cursor=select frac1,frac2,frac3 from table ORDER BY
foo
valGoToRecord(cursor,1) //the first record has the
minimum foo
frac1=valgetfield(cursor,1) etc ...

Which is faster? Is using the MIN function faster than
ORDER BY? I presume so but I don't know by how much -
enough of a difference to justify the extra time
associated with having to obtain the second cursor in
the first approach?

I need to do this many times so I want to use the most
efficient approach.

Best Regards,
Steven

Send instant messages to your online friends http://au.messenger.yahoo.com 


More information about the Valentina mailing list