Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Filtered Query on nth row
Of course you can use PL/SQL and make a loop which returns only desired rows, but try using Oracle's pseudo column RowNum and modulo-function. Problem is that you can not use rownum in where clause so you must first create the result set and then filter desired rows. Statement could be something like this
SELECT ...
FROM ...
GROUP BY (all columns)
HAVING MOD(rownum,5) = 1
I am not sure of this, so test it carefully. Also this uses HEAVILY I/O and CPU, so if the result set is large this may not be the solution you want
Mika Wendelius
System Analyst
Business DataBases Ltd
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.
Received on Fri Feb 06 1998 - 00:00:00 CST