Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Filtered Query on nth row

Re: Filtered Query on nth row

From: Jesper Søndergaard <jsoender_at_NOSPAM.dk.oracle.com>
Date: 1998/02/06
Message-ID: <34DAE94C.A516391D@NOSPAM.dk.oracle.com>#1/1

Jeff Jackson wrote:

> Does anyone know how to do a query and filter every nth row ?
> Example,
> I have 100 rows returned but I am only intereseted in every other fith
>
> row for example.... row1, row6, row11,row16 etc.... I don't want to
> see
> rows 2,3,4,5,7,8,9,10 etc ... Is this possible ?
>
> Does SQL allow me to do this ? I have tried all kinds of queries,
> correlated, inner joins, sub queries and various expressions.

Try to use the ROWNUM column combined with an inline view:

select b.empno
from
(
select empno, mod(rownum,5) xx from emp
) a,
emp b
where a.xx = 1
and b.empno = a.empno;

/Jesper

.·'´`'·.,,.·'´`'·.,,.·'´`'·.,,.·'´`'·.,,.·'´`'·.,,.·'´`'·.,,.·'´`'·.,,.·'´`'·.

|
|
|                            Jesper
 Søndergaard                              |
|                            Technical
 Analyst                              |
|
|
| Email:     jsoender_at_dk.oracle.com                 Oracle
 Danmark           |
| Office:    +45 4480 8081                          Lautrupbjerg
 2-6         |
| Direct:    +45 4480 4269                          DK-2750
 Ballerup         |

|
|
'·.,,.·'´`'·.,,.·'´`'·.,,.·'´`'·.,,.·'´`'·.,,.·'´`'·.,,.·'´`'·.,,.·'´`'·.,,.·'
         The statements and opinions expressed here are my own and
         do not necessarily represent those of Oracle Corporation.
Received on Fri Feb 06 1998 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US