Home » SQL & PL/SQL » SQL & PL/SQL » every 5th row data extraction
every 5th row data extraction [message #19933] Thu, 18 April 2002 23:33 Go to next message
Jay
Messages: 127
Registered: October 1999
Senior Member
If i want to extract every fifth row of from the table what will be the qrery kind of ..? please take an example of emp table here.

thank you
Jay
Re: every 5th row data extraction [message #19935 is a reply to message #19933] Fri, 19 April 2002 00:29 Go to previous messageGo to next message
Mike
Messages: 417
Registered: September 1998
Senior Member
Hi,

It's up to you to define what the 5th row is. There is no information stored in a table about row number or which row is the 5th row.

Mike
Re: every 5th row data extraction [message #19948 is a reply to message #19933] Fri, 19 April 2002 15:18 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
You can use DBMS_RANDOM if you truly want a random selection. If you would rather base the selection on a particular column, you can instead order by that column (example: employee number).

select *
  from (select rownum rn, t.*
          from emp t
         order by dbms_random.random) 
 where mod(rn, 5) = 0
Previous Topic: About installation
Next Topic: Best Indexing Practices??..
Goto Forum:
  


Current Time: Fri Apr 19 13:06:41 CDT 2024