List: General Discussion « Previous MessageNext Message » From: Jim Faucette Date: June 9 1999 2:56pm Subject: Re: Strange sorting on negative numbers of type decimal View as plain text
```eric@stripped wrote:
>
> >Description:
> Sorting on a decimal field with negative numbers cause a strange sequence
> should be -14,-13,-12,-12,-10,-5,-4,-3,-2,-1,0,1,2,3,4,5,10,11,12,13,14
> but is    -10,-11,-12,-13,-14,-1,-2,-3,-4,-5,0,1,2,3,4,5,10,11,12,13,14
>
> The sorting code in isamchk seems to suffer from the same problem.
>
> >How-To-Repeat:
> CREATE TABLE test (
>   num decimal(6,2) DEFAULT '0.00' NOT NULL,
>   KEY num (num)
> );
>
> INSERT INTO test VALUES (-13);
> INSERT INTO test VALUES (-10);
> INSERT INTO test VALUES (-11);
> INSERT INTO test VALUES (-12);
> INSERT INTO test VALUES (-14);
> INSERT INTO test VALUES (-4);
> INSERT INTO test VALUES (-5);
> INSERT INTO test VALUES (-3);
> INSERT INTO test VALUES (-1);
> INSERT INTO test VALUES (-2);
> INSERT INTO test VALUES (0);
> INSERT INTO test VALUES (3);
> INSERT INTO test VALUES (2);
> INSERT INTO test VALUES (1);
> INSERT INTO test VALUES (5);
> INSERT INTO test VALUES (4);
> INSERT INTO test VALUES (13);
> INSERT INTO test VALUES (12);
> INSERT INTO test VALUES (14);
> INSERT INTO test VALUES (10);
> INSERT INTO test VALUES (11);
>
> select num from test order by num;

What does ORDER BY num+0 give you?

jim...
```
Thread
Strange sorting on negative numbers of type decimaleric9 Jun
• Re: Strange sorting on negative numbers of type decimalJim Faucette9 Jun
• Re: Strange sorting on negative numbers of type decimalEric Thelin9 Jun
• Strange sorting on negative numbers of type decimalMichael Widenius9 Jun
• Re: Strange sorting on negative numbers of type decimalBlake Binkley10 Jun
• Re: Strange sorting on negative numbers of type decimalMichael Widenius10 Jun