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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Need help with retriving RANDOM rows from a table.

Re: Need help with retriving RANDOM rows from a table.

From: Thomas Kellerer <spam_eater_at_gmx.net>
Date: Tue, 12 Aug 2003 15:41:49 +0200
Message-ID: <bhaqqt$vt0j0$2@ID-13919.news.uni-berlin.de>

Thomas Kellerer schrieb:

>
>
> LT Cheah schrieb:
>

>> I would like to retrieve only a certain number of rows from a table (of
>> production data) for statistical analysis of certain production test
>> parameters.
>>
>> The table has say 1 million rows and has a Date_Time column with a date
>> format.  How does one relive say the first 20 rows of data for every hour
>> for example.
>>
>> Or is there any other simpler method (by using the ROW_ID for example) 
>> such
>> that a limited random number of rows may be retrived.
>>

>
> Statement.setMaxRows() is what you are looking for:
>
> <http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Statement.html#setMaxRows(int)>
>
>
> Thomas
>

Sorry for the answer. I thought I was still reading comp.lang.java.databases

If you are not using Java/JDBC then you could use the rownum pseudo column for this:

SELECT ...
FROM ...
WHERE ...

AND rownum < 20

Regards
Thomas Received on Tue Aug 12 2003 - 08:41:49 CDT

Original text of this message

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