Re: Months later ... i have an SQL soluce for "what is the rank ofthis data in an index order?"

Author: Stephen Russell

Posted: 2012-07-10 at 14:27:28

On Tue, Jul 10, 2012 at 1:25 PM, Gérard Lochon <g-lochon@wanadoo.fr> wrote:

> ----- Original Message -----

>

>>

>> Is there any value to know the location # from BOF(), and if there is

>> why is closer better depending on index?

>

> BOF() is an XBase iterative function, nothing to do witrh SQL ensembly

> conceipt.

> Somewhere, excluding it.

>

> However; it is always possible to replace this lack of logic.

>

> If we consider the previous example :

>

> [VFP]

>

> CREATE CURSOR test ;

> (lib c(10),mt i)

>

> INSERT INTO test VALUES ("john",10)

> INSERT INTO test VALUES ("jennifer",15)

> INSERT INTO test VALUES ("stella",25)

> INSERT INTO test VALUES ("sophia",40)

> INSERT INTO test VALUES ("greg",50)

> INSERT INTO test VALUES ("jeff",20)

>

> [/VFP]

>

> It is possible to "create a rank" according to a choosen order.

>

> Let's do it. We choose to order "mt" values :

>

>

> [VFP]

>

> SELECT xx.lib, xx.mt, COUNT(yy.mt) as rank ;

> FROM test xx, test yy ;

> WHERE xx.mt <= yy.mt ;

> GROUP BY xx.lib, xx.mt ;

> ORDER BY xx.mt DESC, xx.lib DESC

>

> [/VFP]

>

> Once upon this order is made, we can determine

> a numeric distance delta (your question) from

> BOF() or EOF().

>

---------------------

Does this handle the tie at the #2 rank properly for ranks 3,4&5?

--

Stephen Russell

Sr. Analyst

Ring Container Technology

Oakland TN

901.246-0159 cell

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://leafe.com/mailman/listinfo/profox

OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/CAJidMYLmsAs9Gue_C4pXozRBvUh2HLihboAN-ZqOY1NdvyqCOw@mail.gmail.com

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2012 Stephen Russell