Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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

Answers were Sorted based on User's Feedback



SELECT * FROM (SELECT TITLE FROM MOVIE ORDER BY RANK DESC) WHERE ROWNUM > 4; when i run t..

Answer / rachita

This is because you cannot use > operator with Top-N
Analysis.The operator which is used is only < less-then and
<= less-then-equal-to .You can also use = operator but only
for retrieving the top most value .

Is This Answer Correct ?    13 Yes 1 No

SELECT * FROM (SELECT TITLE FROM MOVIE ORDER BY RANK DESC) WHERE ROWNUM > 4; when i run t..

Answer / vamsi krishna

the reason behind this is rownum will be generated only
after selecting the row from the table.hence when you are
using inline views ,the outer select statement is having a
rownum and inner select statement is having a rownum,so due
to the ambiguity your query is not working.
i give the following change to ur query.
SELECT * FROM
(SELECT rownum as r1,TITLE FROM MOVIE )
WHERE r1 > 4;

Is This Answer Correct ?    5 Yes 4 No

SELECT * FROM (SELECT TITLE FROM MOVIE ORDER BY RANK DESC) WHERE ROWNUM > 4; when i run t..

Answer / 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

SELECT * FROM (SELECT TITLE FROM MOVIE ORDER BY RANK DESC) WHERE ROWNUM > 4; when i run t..

Answer / obed

You donot use '>4' for comparing
you must use '<=4'
if u used >4 its will not return any row because there in
no row is select >

Is This Answer Correct ?    1 Yes 0 No

SELECT * FROM (SELECT TITLE FROM MOVIE ORDER BY RANK DESC) WHERE ROWNUM > 4; when i run t..

Answer / mohan

select * from movie where rownum>4(select title from movie
rank()over(order by title desc);

Is This Answer Correct ?    1 Yes 0 No

SELECT * FROM (SELECT TITLE FROM MOVIE ORDER BY RANK DESC) WHERE ROWNUM > 4; when i run t..

Answer / imran raza

ORDER BY Clause inside Inline View is not permissible.So in
query (SELECT TITLE FROM MOVIE ORDER BY RANK DESC)it should
be only SELECT TITLE FROM MOVIE .
Moreover Order by can be used by specifying the name (
selected row) of coloumn in order by clause.
Instead of names numbers can also be used.ie Order by 1.

Is This Answer Correct ?    1 Yes 1 No

Post New Answer



More Oracle General Interview Questions

query optmization techniques and quwry analyser+projects+ppts

0 Answers  


What is set verify off in oracle?

0 Answers  


What is sequence?

0 Answers  


What is the difference between translate and replace in oracle?

0 Answers  


How do I reset a sequence in oracle?

0 Answers  






Difference between sub query and nested query ?

18 Answers   Keane India Ltd, TCS,


What are the limitations oracle database 10g xe?

0 Answers  


What are the components of Logical database structure of ORACLE database?

4 Answers  


1.What is inline function in oracle and its purpose? 2.What is the equivalent operator for "different from pattern" in oracle? 3. If you define a variable in oracle, how it will be available? [a. Until database shut down b. Until table deleted c. until session get expired]

2 Answers  


What is oracle latest version?

0 Answers  


HOW TO DISPLAY MAXIMUM SALARIES FROM EMP DEPARTMENT VISE ALONG WITH DEPARTMENT NAMES? E.g EMP,DEPT

5 Answers   College School Exams Tests, DELL,


How many different types of indexes we have in oracle?

24 Answers   IBM, TCS,






Categories
  • Oracle General Interview Questions Oracle General (1789)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (509)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)