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!

Distinct rows using rownum

Joseph FranklinNov 16 2015 — edited Nov 16 2015

Need help in using distinct and rownum. In the sample SQL below I need to get distinct 100 rows. What is happening in my query is first the 100 records are selected and then it applies distinct which ends in giving less records in the output.

We join many tables and the database size is huge, so we want to restrict the query run on full population. Any solution available to get 100 distinct without theĀ  query being executed for full population?

select distinct ename from emp

where rownum <=100

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 14 2015
Added on Nov 16 2015
9 comments
2,242 views