Home » RDBMS Server » Server Utilities » Is there any command similar to SQLSERVER TOP command in Oracle
Is there any command similar to SQLSERVER TOP command in Oracle [message #72183] Fri, 04 April 2003 12:35 Go to next message
skrosuri
Messages: 1
Registered: April 2003
Junior Member
Hi,
Is there any command similar to SQLSERVER TOP command in Oracle. I would like to get the last item in the table.
Thanks,
Re: Is there any command similar to SQLSERVER TOP command in Oracle [message #72184 is a reply to message #72183] Fri, 04 April 2003 22:13 Go to previous message
Barbara Boehmer
Messages: 9097
Registered: November 2002
Location: California, USA
Senior Member
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
/
Previous Topic: Passing the data filename parameter in my table?
Next Topic: Size of a Table
Goto Forum:
  


Current Time: Fri Jun 28 15:37:06 CDT 2024