SELECT * FROM
(SELECT TITLE FROM MOVIE ORDER BY RANK DESC)
WHERE ROWNUM > 4;

when i run the above query .it produces output as NO ROWS
SELECTED.why ?plz any one help me

Answer Posted / dinesh a.

you can't use rownum > 4 ( you can use only rownum <
clause). not in inner query or inline view even in normal
query.

select empno from emp where rownum > 5 ..
The output you will get NO ROWS always ....

so the magic is only order by clause asc or desc pls see
below
suppose we have a table x with one column col1 and values
are 1 to 10...

SELECT rownum,rank,col1 FROM
(SELECT rownum rank,col1 FROM x ORDER BY col1 desc)
WHERE ROWNUM <= 6 /* last six rows mean > 4 */
/

ROWNUM RANK COL1
------ ---------- ----------
1 10 10
2 9 9
3 8 8
4 7 7
5 6 6
6 5 5
1 SELECT rownum,rank,col1 FROM
2 (SELECT rownum rank,col1 FROM x ORDER BY col1 asc)
3* WHERE ROWNUM <= 4 /* first 4 rows */
SQL> /

ROWNUM RANK COL1
---------- ---------- ----------
1 1 1
2 2 2
3 3 3
4 4 4

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to display employee records who gets more salary than the average salary in the department?

597


Explain the use of indexes option in imp command.

566


How do I know if oracle is installed on windows?

486


How to rollback the current transaction in oracle?

538


How do I limit the number of oracle database connections generated by weblogic server?

547






Explain the difference between a procedure and a function? What do you understand by those terms?

624


Explain the use of Merge statement in oracle 11g

596


Explain the use of consistent option in exp command.

552


What is the difference between formal parameters and actual parameters?

545


Explain a data segment?

649


What is an oracle and why it is used?

623


What is ceil and floor in oracle?

577


What are the major difference between truncate and delete?

519


Can we create trigger on materialized view in oracle?

565


How to establish administrator authentication to the server?

558