Hi Monks
I have the results from a SQL statement. I wish to order it in an unusual way . The main key I want to use to order them is a memory key. I want to order them in loop starting with the smallest value "0" and moving up to the largest "256". Then I want to repeat the process for the rest of the values ie 0, 2, 4, 8, 16, 32, 64, 128, 256, 0, 2, 4, 8, .....
The values are ordered correctly (as above) in my database but when I retrieve them using a rather complicted SQL statement they become sorted ie 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4.......
Another problem I have is that all the Zero values are stored as null in the database. After my SQL statement is run it sends all the nulls to the end of the file. Unfortunatly not all the nulls are Zeros. Some are in fact nulls.
I'm comparing two tables using an outer join so some of the nulls would be non comparable results ie a result from table one
that can't be matched to the second table.
memory . memory .
. . . .
. . . .
. . . .
256 78879 256 8706 [Full result ordered
256 80700 256 7898 incorrectly (most common)]
256 53454 256 2345
-- 76896 -- 7860 [Result for 2
-- 76967 -- 8087 zero values]
-- 34456 -- 2344
-- -- 2 7697 [No comparable values]
-- -- 2 7696
-- -- 2 7687
-- -- 2 7869
-- -- 4 6797
2 6798 -- --
2 7008 -- --
. . . .
. . . .
. . . .
So what I am hoping to do is
1) Order the results in the desired way.
2) Seperate nulls from zeros.
Any ideas are appreciated. I realise that this is a complex issue but even bit answers and suggestions are helpful.
Thanks Guys.
j
o
h
n
i
r
l
.
Sum day soon I'Il lern how 2 spelI (nad tYpe)
In reply to Sorting
by johnirl
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.