Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: nth record?
Hi,
>Is there a way to grab the nth record, using Oracle? I would like to
>pull a specific number of records at random. Maybe, using every 5th,
>6th, 7th ect., record. Any suggestions.
Use a cursor, example:
declase
cursor c1 is ;
begin
for r1 in (select * from your_table) loop
if mod(c1%rowcount,7) = 0 then
do_your_thing
end if;
end loop;
end;
You can also use a (semi-) random function. Those are posted here regularly.