1、需要用到row_number()
2,select id,row_no
from
(select id, row_number() over( partition by 如果有需要分组的请加顷拦上,order by id ) as row_no
from table
) xx
where xx.row_no = 5
需要什么填丛乎空写什么数字就好了。渗瞎
select id
from
(
select id
from tableA
order by id
) tab
where rownum=5
Maybe you can try it below by yourself :
select *
from table
where count (id)=5
If it doesn't work for you, can you tell me the right answer to the question you have got and tried ??
Thanks!!!
select top 1 * from
(select top 5 * from table order by id) order by id desc
select top 5 * from tb where id not in (select top 4 id from tb order by id)
order by id