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!

ORA-00918: column ambiguously defined and rownum

707291Nov 10 2011 — edited Nov 10 2011
I have a bunch of sqls in application with select distinct .. from .. where..
application restricts no of rows retrieved
earlier code uses to append where clause to add rownum < rownum_limit
i.e

select distinct .. from .. where..
and rownum <= &rownum_limit;

since distinct and rownum do not go well i have modified it to use subquery:
select * from (select distinct .. from .. where..
) where rownum <= &rownum_limit;

This is giving correct results but introduced another issue when subquery has duplicate column names its, started giving
ORA-00918: column ambiguously error.

I am dealing with application level changes so it may not be case of changing single sql and resolving columns with alias names.

Please suggest ?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 8 2011
Added on Nov 10 2011
4 comments
3,290 views