By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,711 Members | 2,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,711 IT Pros & Developers. It's quick & easy.

does sqlplus support :"select top 10 * from table1" syntax like MS SQL?

P: n/a
I would like to select the top 10 record from a table? How can I do it?
In MS SQL, it's easy using select top 10 from table1. But in oracle database,
I can't use top, anyone have any suggestions? Thanks!
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"mlke" <ml***@hotmail.com> wrote in message
news:df**************************@posting.google.c om...
I would like to select the top 10 record from a table? How can I do it?
In MS SQL, it's easy using select top 10 from table1. But in oracle database, I can't use top, anyone have any suggestions? Thanks!


I do not know SQL server, but I think that you want to do what is called Top
'N' Analysis. In Oracle you can do this through an inline view. I found the
explanation inserted at the bottom of this post on
http://www.orafaq.com/msgboard/serve...sages/7285.htm :

Best regards,

Jacob Grydholt Jensen

----

Posted by Barbara Boehmer (66.120.226.1) on April 05, 2003 at 02:13:35:

In Reply to: Is there any command similar to SQLSERVER TOP command in Oracle
posted by skrosuri on April 04, 2003 at 16:35:18:

In Oracle, top-n analysis is accomplished by first ordering the values in an
inner sub-query, then selecting the rows from an outer query. You can use
DESC in the order by clause to get the last row, rather than the first row.
Oracle does not guarantee the row returned until or unless an order by
clause has been applied.


SELECT *

FROM (SELECT column_names

FROM table_name

ORDER BY column_name DESC)

WHERE ROWNUM <= 1

/
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.