Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Sort table by a specific order
Phill
Hello,
i read some information from the database, and show it with a table.
Now i want to sort the Table, but i a specefic order.
I get via Params a list with the ids from the rows, and i want to sort like the ids in the list are.
e.g. the list: 6, 2, 3, 10, 5
And now i want to sort the table in the order with the list above.
These are the ids from my rows.
It isn't ASC or DESC ... it's free order.
How i can do this?
thanks
Find more posts tagged with
Comments
mcremer
<blockquote class='ipsBlockquote' data-author="'Phill'" data-cid="84024" data-time="1318417928" data-date="12 October 2011 - 04:12 AM"><p>
Hello,<br />
i read some information from the database, and show it with a table.<br />
<br />
Now i want to sort the Table, but i a specefic order.<br />
I get via Params a list with the ids from the rows, and i want to sort like the ids in the list are.<br />
<br />
e.g. the list: 6, 2, 3, 10, 5<br />
<br />
And now i want to sort the table in the order with the list above.<br />
These are the ids from my rows.<br />
It isn't ASC or DESC ... it's free order.<br />
<br />
How i can do this?<br />
<br />
thanks<br /></p></blockquote>
<br />
<br />
If its query based you could do somting like this:<br />
<br />
your parm input is somting like this: 6;2;3;10;5<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
SELECT rownum sortid, TRIM (SUBSTR ('6;4;3;2;4;6;7;9'
, INSTR ('6;4;3;2;4;6;7;9', ';', 1, LEVEL) + 1
, INSTR ('6;4;3;2;4;6;7;9', ';', 1, LEVEL + 1) - INSTR ('6;4;3;2;4;6;7;9', ';', 1, LEVEL) - 1
)
) AS example
FROM DUAL
CONNECT BY LEVEL <= LENGTH ('6;4;3;2;4;6;7;9') - LENGTH (REPLACE ('6;4;3;2;4;6;7;9', ';', '')) - 1
</pre>
<br />
If you add this query with the with clouse you can sort on the sortid
and do as you pleasue.