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

Ruslan Zasukhin sunshine at public.kherson.ua
Mon Nov 27 09:20:47 CST 2006


On 11/27/06 2:50 AM, "Steven Ronald" <stevenrt39 at yahoo.com.au> wrote:

Hi Steven,

> 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? 

First of course.

> 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.

Always possible to so some benchmark.

-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]




More information about the Valentina mailing list