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: Tricky SQL Problem: Top "n" of queried records

Re: Tricky SQL Problem: Top "n" of queried records

From: <larionov_at_yahoo.com>
Date: 1998/03/25
Message-ID: <6fbmha$op2$1@nnrp1.dejanews.com>#1/1

try then:
select distinct object_id, object_name from all_objects where ROWNUM < 4
order by object_id

I think, Oracle does some sorting when you are using the keyword "distinct"

By the way, is there an index on object_id?

Michael.

In article <6f95kq$jhk$1_at_nnrp1.dejanews.com>,
>
> In Oracle, this session:
>
> SQL> select object_id, object_name from all_objects
> 2> where ROWNUM < 4
> 3> order by object_id
>
> returns:
>
> OBJECT_ID OBJECT_NAME
> ---------- ---------------
> 78 ACCESS$
> 934 ALL_ARGUMENTS
> 984 ALL_ALL_TABLES
>
> very quickly - also subsecond, but it does not represent the correct
 dataset.
> The first three object_id values should be 3, 4, and 5.
>

-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/ Now offering spam-free web-based newsreading Received on Wed Mar 25 1998 - 00:00:00 CST

Original text of this message

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