Re: ORDER BY vs. UPDATE
Posted in 1992
Or then again, how about this:
1. Create a temp table called foo. Foo will have two columns: old_rank
and new_rank.
2. define p_old_rank integer
define j integer
3. declare mr_fix_it cursor for
select unique(old_rank)
from real_table
order by old_rank;
4. let j = 1
5. foreach mr_fix_it into p_old_rank
insert into foo values (p_old_rank, j)
let j = j + 1
end foreach
6. Now in your query...
select real_table.*, new_rank
from real_table, foo
where real_table.old_rank = foo.old_rank
order by new_rank
7. Just use the column new_rank instead of old_rank.
Clear as mud?
CAVEAT: I just wrote this "off the cuff" and I would be greatly surpised if
there weren't more than a few syntax errors. :)