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!

Oracle SQL - How to limit rows and include the tied columns in the result

RAMMIIMar 18 2017 — edited Apr 4 2017

Hi ... I have one issue with particular  PL SQL query (ordering specific column ), i am trying to limit the number of rows in the query but i wanted to include the tied rows also of that ordering column as well.

I think in 12c we have some function like FETCH FIRST N WITH TIED ROWS  but i have older version of Oracle.

Could you please let me know how can I handle this scenario, is it possible with joins or something.

EXAMPLE :

CLM1  CLM2

  A1        1

  A2        1

  A3        1

  A3        2

  A4        1

  A5        1

I want to get the first 3 records of CLM1 but when it matches the next rows i should fetch those also in my result.

sample query i am using but it's not suit for my requirement.

select * from T  where  rownum <4 order by CLM1

Please help me with this query.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 2 2017
Added on Mar 18 2017
8 comments
2,965 views