how to find 5th row ?

Answers were Sorted based on User's Feedback



how to find 5th row ?..

Answer / sunil bisht

Hi Shajin
above answere is perfectly correct.
but i have one more method..


select * from emp where rownum<6 minus select * from emp
where rownum<=4;

Is This Answer Correct ?    22 Yes 3 No

how to find 5th row ?..

Answer / subhani

some of above have used corelated subqueries but it is not
recommonded to use.
best way is
select * from emp where rownum<=5
minus
select * from emp where rownum<5;

Is This Answer Correct ?    11 Yes 1 No

how to find 5th row ?..

Answer / suresh babu

SELECT * FROM t1 a
WHERE 5 = (SELECT COUNT(rowid)
FROM t1 b
WHERE a.rowid >= b.rowid);

This Query,Which is used to find 5 record from Table.

Is This Answer Correct ?    10 Yes 5 No

how to find 5th row ?..

Answer / anil

select * from emp where rownum <=5 minus
select * from emp where rownum <5

Is This Answer Correct ?    1 Yes 0 No

how to find 5th row ?..

Answer / swastik

SELECT * FROM
          (
           SELECT ROWNUM Rn, E1.*
           FROM Emp
           )
WHERE RN = 5
/

Is This Answer Correct ?    1 Yes 0 No

how to find 5th row ?..

Answer / suresh babu

select * from table_name tn1 where 5 = (select count(rowid)
from table_name tn2 where tn1.rowid >= tn2.rowid);

This query,which is display the 5th row in table.

Is This Answer Correct ?    2 Yes 2 No

how to find 5th row ?..

Answer / bikash khuntia

Hi Freinds,

I have seen the solution given. But in oracle if you will
select records from a table then everytime you will not
fetch the same squence of records. it will come
differently.Hence we cannot select the 5th row from a table
in oracle.

But the solution is that we can select 5th row from a table
in arranging the records in ascending or descending way by
a column and then select the 5th row as below:-

SELECT BIKK.SAL FROM
(SELECT ROWNUM RW,BIK.SAL SAL FROM (SELECT SAL FROM
TEMP_SAL ORDER BY SAL) BIK) BIKK
WHERE rw=6

Is This Answer Correct ?    0 Yes 1 No

how to find 5th row ?..

Answer / alok narayan

1.
select * from emp e1 where 5 =( select count(rowid) from
emp e2 where e1.rowid >= e2.rowid) ;

Is This Answer Correct ?    1 Yes 3 No

how to find 5th row ?..

Answer / krish

select * from(select * from emp order by rowid desc)where
rownum=5;

Is This Answer Correct ?    1 Yes 7 No

how to find 5th row ?..

Answer / sanket.infy

select * from table t1 where rownum = 5 ;

Is This Answer Correct ?    1 Yes 31 No

Post New Answer

More SQL PLSQL Interview Questions

Can unique keys be null?

0 Answers  


what are the advantages of using stored procedures? : Sql dba

0 Answers  


Define join and name different types of joins?

0 Answers  


What is group by in sql?

0 Answers  


How to get the 3rd column(i.e all the data along with the column name)in a table?

2 Answers   Logica CMG,






SELECT emp_num, years, SUM(salary) FROM sales UNION ALL SELECT emp_id, SUM(takehomepay) FROM marketing What error is present in the sample code above? 1. Queries being combined with the UNION ALL statement are not allowed to have SELECT lists with a different number of expressions. 2. You are not allowed to use aggregate functions within two queries joined by a UNION ALL statement. 3. The UNION ALL statement incorrectly combines the "years" result from the first query with the "SUM (takehomepay)" result from the second query. 4. Unless the UNION ALL statement is replaced with a UNION statement, the queries will return duplicates. 5. The "emp_id" column from the second query must be renamed (or aliased) as "emp_num" so that it corresponds to the column name from the first query. Otherwise, the queries will not execute.

3 Answers  


Use The Implicit cursor to Query The Department table information Where Deptno is 30.check,if no record was found then print "Record Was Not Found".Else Print Deptname And Ename.Dept table Have Dname Varchar2(20),Deptno Number,EnameVarchar2(20).Please Answer In 2 mins,with in Maximum 15 lines.

5 Answers   Wipro,


In a Distributed Database System Can we execute two queries simultaneously ? Justify ?

3 Answers  


Explain what is rdbms?

0 Answers  


What is the purpose of primary key?

0 Answers  


how to check the 3rd max salary from an employee table?

23 Answers   IBM,


how do you count the duplicate records in a table

10 Answers   Tech Mahindra,


Categories