Re: Select Top ... * from ... command

From: Mark D Powell <Mark.Powell_at_eds.com>
Date: 9 Jul 2003 06:52:38 -0700
Message-ID: <2687bb95.0307090552.606b4dd7_at_posting.google.com>


bigjobbies_at_hotmail.com (Ethel Aardvark) wrote in message news:<1a8fec49.0307090049.3f4099c4_at_posting.google.com>...
> Either:
>
> select *
> from myTable
> where rownum <= 100
>
> or
>
> rtfm
>
> ETA
>
>
> jdragon <member32810_at_dbforums.com> wrote in message news:<3087807.1057697008_at_dbforums.com>...
> > In SQL Server, I can execute this query -> select top 100 * from myTable
> >
> > How do I do this in Oracle?

Jdragon, I think Ethel gave you the correct answer; however, if TOP in mySQL does something like looks at the PK for the 'TOP' rows then you would code the SQL something like:

select * from ( select * from tablex where ... order by desired_key) where rownum < some_limit;

This is a TOP-N query and can be used to obtain the top N values based on the order by clause.

HTH -- Mark D Powell -- Received on Wed Jul 09 2003 - 15:52:38 CEST

Original text of this message