如何选择另一个选择查询结果的第10行,第20行,第30行...

时间:2016-01-19 09:43:35

标签: sql oracle oracle12c

我的表格中包含;WITH CTE AS ( SELECT top 1000 * FROM test WHERE order_num IN( select order_num FROM test WHERE TO_DATE (mod_dt) BETWEEN TO_DATE ('11-JUN-15') AND TO_DATE ('17-JUL-15') AND REGION = 'AK') ) delete * from CTE; tofrom列。我只需要选择每{10} ID IDA的行。

2 个答案:

答案 0 :(得分:4)

select * from 
(select * from table where from = 'A' and to ='B' order by ID)
where mod(rownum/10,1) = 0

首先只需要来自' A'到' B'然后给他们rownums,并且只选择那些在ETC第10个地方的那些..

答案 1 :(得分:-1)

或者您可以使用

select from, to, id 
from table1 
where id like'%0' and from ='A' and to = 'B'