SQL query times out when ROWNUM column added to it

I have the first query that works. But then I added ROWNUM column to try to paginate the results. Now it seems to just times out without returning any results. Do not understand the issue here on the Oracle database.

// Working
select 
    tablea.* 
from 
    (select 
         vcell.operator_name, vcell.vendor_name, 
         v_territory.territory_label as Region, 
         v_zone.zone_short_name as Zone, v_cluster.cluster_nm, 
         vcell.engineering_number, v_location.loc_site_long_nm as Name,
         vcell.Band infoband, vcell.Freq_Band infofreqband, 
         vcell.Carrier infocarr, vcell.channel_bandwidth infobandwidth, 
         vcell.cell_type infocelltype, vcell.enodeb_id infoenbid, 
         vcell.local_cell_id infocellid, vcell.ecell_name infocellname, 
         vcell.Sector infosector, vcell.Channel infochannel,
         vcell.physical_cell_id infopci, vcell.TAC infotac, 
         tbl.* 
     from
         cim.v_zone v_zone, cim.v_cluster v_cluster, 
         cim.v_territory v_territory, cim.v_location v_location,
         cim.v_cell_lte vcell, netact_b_lnd.SRAN_CELL_LNCEL tbl 
     where
         v_zone.zone_label = '9' 
         and v_location.operator_name = 'Base' 
         and vcell.operator_name = 'Box' 
         and vcell.vendor_name = 'N' 
         and v_zone.zone_id = v_cluster.zone_id 
         and v_territory.territory_id = v_zone.territory_id 
         and v_cluster.cluster_id = v_location.cluster_id 
         and vcell.engineering_number = v_location.engineering_number 
         and SUBSTR(tbl.DISTNAME, INSTR(tbl.DISTNAME,'LNBTS-',1) + 6, 6) = vcell.enodeb_id
         and REPLACE(SUBSTR(tbl.DISTNAME, INSTR(tbl.DISTNAME, 'LNCEL-', 1) + 6, INSTR(SUBSTR(tbl.DISTNAME || '/', INSTR(tbl.DISTNAME,'LNCEL-',1) + 6, 4),'/',1)),'/','') = vcell.local_cell_id 
       order by tbl.distname) tablea

// Not working
select 
    tablea.*, ROWNUM 
from 
    (select
         vcell.operator_name, vcell.vendor_name, 
         v_territory.territory_label as Region, 
         v_zone.zone_short_name as Zone, v_cluster.cluster_nm, 
         vcell.engineering_number, v_location.loc_site_long_nm as Name,
         vcell.Band infoband, vcell.Freq_Band infofreqband, 
         vcell.Carrier infocarr,vcell.channel_bandwidth infobandwidth, 
         vcell.cell_type infocelltype, vcell.enodeb_id infoenbid, 
         vcell.local_cell_id infocellid,vcell.ecell_name infocellname,
         vcell.Sector infosector, vcell.Channel infochannel,
         vcell.physical_cell_id infopci, vcell.TAC infotac, 
         tbl.* 
     from
         cim.v_zone v_zone,cim.v_cluster v_cluster, 
         cim.v_territory v_territory, cim.v_location v_location,
         cim.v_cell_lte vcell, netact_b_lnd.SRAN_CELL_LNCEL tbl 
     where
         v_zone.zone_label = '9'  
         and v_location.operator_name = 'Base' 
         and vcell.operator_name = 'Box' 
         and vcell.vendor_name = 'N' 
         and v_zone.zone_id = v_cluster.zone_id 
         and v_territory.territory_id = v_zone.territory_id 
         and v_cluster.cluster_id = v_location.cluster_id 
         and vcell.engineering_number = v_location.engineering_number 
         and SUBSTR(tbl.DISTNAME, INSTR(tbl.DISTNAME,'LNBTS-',1) + 6, 6) = vcell.enodeb_id
         and REPLACE(SUBSTR(tbl.DISTNAME, INSTR(tbl.DISTNAME,'LNCEL-',1) + 6, INSTR(SUBSTR(tbl.DISTNAME || '/', INSTR(tbl.DISTNAME,'LNCEL-',1) + 6, 4),'/',1)),'/','') = vcell.local_cell_id 
       order by tbl.distname) tablea  
where 
    ROWNUM <= 5

I was following this page to do pagination on Oracle database.
https://blogs.oracle.com/connect/post/on-rownum-and-limiting-results

New contributor

Sanjaya Kasun is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật