Home » RDBMS Server » Server Administration » Re: retriving last 10 rows
Re: retriving last 10 rows [message #374702] Mon, 25 June 2001 12:13
Sudhakar Atmakuru
Messages: 58
Registered: May 2001
Member
The above reply does not work in your version of ORACLE. The query mentioned after FROM is used to create an instant virtual table from which it has to retrive the data rows. This is allowed only in ORACLE8i or above. Let us try in other way. Try this one out and please let me know immediately by mailing at satmakuru@yahoo.com

select * from emp where rowid in
(select rowid from emp
minus
select rowid from emp where rownum<= (select count(*)-10 from emp));

Since I am not so sure about the availability of rowid in your version of oracle, please let me know if it is working.

Explanation for the answered query:

The main select statement returns the rows which are existing in the rowset returned by the subquery, where as the subquery returns last ten rows by, first, counting the total number of rows and excluding those last 10 rows in the second part of query output. So MINUS causes the first part of query to print the 10 rows that are excluded in the second part of the query.

I guess you understand the answer. Let me know you still need better explanation.
Previous Topic: Matrix Query
Next Topic: SQL Loader: re-enabling constraints
Goto Forum:
  


Current Time: Mon Dec 23 19:17:37 CST 2024