lokesh kumar
lokesh kumar

Reputation: 981

How can I select 10th, 20th, 30th ... row of the result of another select query

I have a table with a column to, from and ID. I need to select only rows with every 10th ID which is from A to B.

Upvotes: 1

Views: 846

Answers (2)

Raffaello.D.Huke
Raffaello.D.Huke

Reputation: 552

Or you can just use

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

Upvotes: -1

sagi
sagi

Reputation: 40491

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

It first takes only those from 'A' to 'B', then giving them rownums, and selecting only those in the 10th 20th ETC places..

Upvotes: 4

Related Questions