Re: Getting a grip on nested intervals and matrix encoding

From: creecode <creecode_at_gmail.com>
Date: Sun, 12 Sep 2010 14:24:30 -0700 (PDT)
Message-ID: <e8386307-c193-4f8c-9976-4a82b1390779_at_l32g2000prn.googlegroups.com>


Hello Vadim,

On Sep 7, 8:47 am, Vadim Tropashko <vadim..._at_gmail.com> wrote:

> select name, (a11-a12)/(a21-a22)*10000000000-a11/a21 pos from hier;
> 1.1.84.23            14970398968.901930438437591866304249136
> 1.1.84.23.1          14970398968.9019304695082500851489389089

With your example results I've been able to get the order position query working. Thanks once again for your help and patience! My original problem with the query was partly due to not using enough precision. I had experimented with greater precision before asking for help but obviously I didn't go far enough! :-)

Here is the query I came up with for MySQL v5.0.x for greater precision...

SELECT name, materialized_path, ( a11 - a12 + 0.00000000000000000 ) /
( a21 - a22 + 0.00000000000000000 ) * ( 10000000000 +
0.00000000000000000 ) - ( a11 + 0.00000000000000000 ) / ( a21 +
0.00000000000000000 ) AS order_position FROM MatrixTreeNodes;

...and the results...

name	materialized_path	order_position
KING	1	9999999998.000000000000000000000000000000
JONES	1.1	9999999998.500000000000000000000000000000
SCOTT	1.1.1	9999999998.666666666666666666666666666667
ADAMS	1.1.1.1	9999999998.750000000000000000000000000000
FORD	1.1.2	13333333331.933333333333333333333333333333
SMITH	1.1.2.1	13333333331.958333333333333333333333333333
BLAKE	1.2	14999999998.333333333333333333333333333333
ALLEN	1.2.1	14999999998.400000000000000000000000000000
WARD	1.2.2	15999999998.375000000000000000000000000000
MARTIN	1.2.3	16249999998.363636363636363636363636363636

Toodle-looooooooo..............
creecode Received on Sun Sep 12 2010 - 23:24:30 CEST

Original text of this message