简体   繁体   English

Oracle数据库之间的行数

[英]Oracle Database Rownum Between

There are 25 records in this sql query I want to get between 5 and 10. How can I do it ? 我想要在5到10之间的这个SQL查询中有25条记录。我该怎么办? I use 11g 我用11克

select
(
    select count(*) as sayfasayisi
    from konular t
    where t.kategori is not null
) as sayfasayisi,
t.id,
t.uye,
t.baslik,t.mesaj,t.kategori,t.tarih,
t.edittarih,t.aktif,t.indirimpuani,t.altkategori,t.link,
nvl(
    (select case when t.id = f.konuid and f.uye = 'test' then '1' else '0' end
     from takipkonu f where t.id = f.konuid and f.uye = 'test'), '0') as takip
from konular t
where t.kategori is not null

You can use ROW_NUMBER() to assign a row number based on some ordering logic contained in your current query, eg a certain column. 您可以使用ROW_NUMBER()根据当前查询中包含的某些排序逻辑(例如某个列ROW_NUMBER()来分配行号。 Then, retain only the 5th to 10th records: 然后,仅保留第5至10条记录:

select t.*
from
(
    select
    (
        select count(*) as sayfasayisi
        from konular t
        where t.kategori is not null
    ) as sayfasayisi,
    ROW_NUMBER() OVER (ORDER BY some_col) rn,
    t.id,
    t.uye,
    ...
) t
where t.rn between 5 and 10;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM