Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

problem with numbers order by

557899Jul 18 2008 — edited Jul 18 2008
i have a requirement where i need to sort the records based on the number. I want the output like
-1,null,0,1,2,3 if asc.
3,2,1,0,null,-1 if desc

i am doing
select * from table order by col asc, but the null row is coming either last or first based on asc or desc.

please let me know how can i do it.

Comments

Cherif bh

Hello Kim,
Thanks for the idea. I think this would be helpful in case we need to execute the entire bloc with on remote DB and avoid execution plan change at least of The with bloc.
Currently we should put many hint no_merge driving_site,materialize , ...

May be a hint would be more easy / more felexible to implement for Oracle and Oracle users.
For example
with collocated_sqf as (
select /*+ WITH_DB_LINK */
remote_d.loc
, remote_e.empno
, remote_e.ename
, remote_e.job
from emp@my_db_link remote_e
join dept@my_db_link remote_d
on remote_d.deptno = remote_e.deptno
where remote_d.dname = 'SALES'
)
select
csqf.loc
, csqf.empno
, csqf.ename
, csqf.job as remote_job
, local_e.job as local_job
from collocated_sqf csqf
left outer join emp local_e
on local_e.empno = csqf.empno;
Thanks

1 - 1
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 15 2008
Added on Jul 18 2008
6 comments
2,274 views