View Single Post

   
  #9 (permalink)  
Old 02-27-2008, 12:44 PM
Brian Tkatch
 
Posts: n/a
Default Re: Sorting weirdness?

On Thu, 07 Jun 2007 00:16:36 +0200, Lennart
<erik.lennart.jonsson@gmail.com> wrote:

>Brian Tkatch wrote:
>[...]
>> To see the order:
>>
>> DECLARE GLOBAL TEMPORARY TABLE Charmap (Num INT, Digit CHAR(1))
>>
>> BEGIN ATOMIC
>> DECLARE A INT DEFAULT 0;
>> WHILE A < 257 DO
>> INSERT INTO
>> SESSION.Charmap(Num, Digit)
>> VALUES (A, CHR(A));
>> SET A = A + 1;
>> END WHILE;
>> END
>>
>>
>> SELECT Num, Digit FROM SESSION.Charmap ORDER BY Num
>> SELECT Num, Digit FROM SESSION.Charmap ORDER BY Digit
>>
>> DROP TABLE SESSION.Charmap
>>
>> The ORDER BY Digit will show the order used.
>>
>> B.

>
>Thanks, another variant without a session table:
>
>with charmap(num, digit) as (values (30,chr(30)) union all select num+1,
>chr(num+1) from charmap where num < 100) select * from charmap order by
>digit


Silly me. I *still* haven't integrated recursive WITHs into my noggin.
Thanx for the lesson!

>
>I used a smaller interval to avoid scrambling of the screen


Considering the order changes a lot, showing every character may be
advantageous.

B.

B.
Reply With Quote