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: selecting only 10 rows

Re: selecting only 10 rows

From: Richard 'Frog' Barrott <u952297_at_student.canberra.edu.au>
Date: Fri, 8 Jan 1999 16:25:12 +1100
Message-ID: <Pine.SOL.3.95.990108162041.24586A-100000@student.canberra.edu.au>


On Thu, 7 Jan 1999, Ed Zappulla wrote:

> Does anyone know how to limit the number of rows returned from a select
> statement? I have 5000 rows in a table and just want to grab the first 10
> to look at a sample of them. I thought ROWId would do it but it doesn't
> seem to work. SQLSERVER uses set rowcount = 10.

Hi Ed.

There's been a big discussion on this topic here recently. Look for the subject "tricky sql question"; this about when you need a certain ten rows but if you don't care which 10 rows are returned, it's much easier.

For example:

SELECT col1,col2,col3
FROM some_table
WHERE some_conditions AND

      ROWNUM < 11;

ROWNUM is incremented by 1 from 0 for each row returned by a query, BUT, if you
use an ORDER BY clause, the final order of the rows does not match their rownum.

Hope this helps.

Received on Thu Jan 07 1999 - 23:25:12 CST

Original text of this message

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