Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Given a table with one int column with random int ordered, write a query to get sorted asc and desc, as 2 columns of output
-- the idea here is to populate rownum after sorting is done
-- if sorting is done along with row num, it defeats the purpose
-- rowid, does not help, since it almost generates a hascode value like
with l_table as (
select measure_id from int_table order by 1 asc
), r_table as (
select measure_id from int_table order by 1 desc
select left_table.measure_id , right_table.measure_id from
(select rownum theid, measure_id from l_table) left_table
inner join
(select rownum theid, measure_id from r_table) right_table
on left_table.theid = right_table.theid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.