Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


suppose we have a table in which 200 rows. i want to find
101 row ? what the query....
and how we find 4th and 5th highest salary and 1 to 10
highest salary

Answers were Sorted based on User's Feedback



suppose we have a table in which 200 rows. i want to find 101 row ? what the query.... and how we..

Answer / umesh h

Use Minus Operator
select * from emp where rownum<=101
minus
select * from emp where rownum<=100;
Here minus will display data only from first query minusing
from 2 query.

Is This Answer Correct ?    3 Yes 0 No

suppose we have a table in which 200 rows. i want to find 101 row ? what the query.... and how we..

Answer / vishnu

if you have table temp_test1

you fire
select * from temp_test1
now you want 101 rows
basic thing here is records are sorted by rowid as per
insertion

for 101 th row

select * from temp_test1 where rowid in(
(select max(rowidtochar(rowid)) from temp_test1 where
rownum<102))
this is asked in tech mahindra

Is This Answer Correct ?    3 Yes 1 No

suppose we have a table in which 200 rows. i want to find 101 row ? what the query.... and how we..

Answer / meher

Let the table name is EMP

To find 101st row the query is as below:

select * from EMP where rownum <= 101
minus
select * from EMP where rownum <= 100;


for Nth salary the query is as below:

SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT
(DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal);

Is This Answer Correct ?    2 Yes 0 No

suppose we have a table in which 200 rows. i want to find 101 row ? what the query.... and how we..

Answer / priya

Here It is asked for 101 row. It does not mean ascending or
descending order.
So query goes like this

Ans:select * from emp where rowid in(
select max(no) from
(select rowid as no,sal from emp where rownum<102));

To Find the 101th row higest salary
Ans:
select max(sal) from (
select * from emp order by sal) s where rownum<102;

similarly for 4th highest it is 5 and for (n-1)th sal it is
n.

Is This Answer Correct ?    1 Yes 0 No

suppose we have a table in which 200 rows. i want to find 101 row ? what the query.... and how we..

Answer / hemant

select * from emp where (rowid,0) in
(select rowid,mod(rownum,101) from emp)
and rownum=1

Is This Answer Correct ?    4 Yes 4 No

suppose we have a table in which 200 rows. i want to find 101 row ? what the query.... and how we..

Answer / m.raghu

answer for 101th record

select * from emp where empno in( select decode
(rownum,&n,empno) from emp);

for 4th highest sal

select distinct sal from(select empno,dense_rank() over
(order by sal desc) rnk from emp) where rnk=&n;

for 5th highest sal give n value=5
for 1-10

select distinct sal from(select empno,dense_rank() over
(order by sal desc) rnk from emp) where rnk<=&n;

Is This Answer Correct ?    1 Yes 1 No

suppose we have a table in which 200 rows. i want to find 101 row ? what the query.... and how we..

Answer / basavaraj yadwad

Let Table name : Employee
Let the columns: Employee_name, Salary

To find 101st row:

select * from (select * from Employee order by
emplayee_name) where rownum = 101

To find 4th highest salary

select * from (select * from Employee order by salary desc)
where rownum = 4


To find 5th highest salary

select * from (select * from Employee order by salary desc)
where rownum = 4


To find 1 to 10 highest salary

select * from (select * from Employee order by salary desc)
where rownum < 11

Is This Answer Correct ?    9 Yes 15 No

Post New Answer

More SQL PLSQL Interview Questions

What cursor type do you use to retrieve multiple recordsets?

17 Answers   Apollo, CTS, IonIdea, Microsoft, Oracle, TCS, Vmoksha, Wipro,


Where do we use pl sql?

0 Answers  


What are the Restrictions on Cursor Variables?

2 Answers  


What are the types of variables use in pl sql?

0 Answers  


Is oracel sql developer written in java?

0 Answers  


What is indexing in sql and its types?

0 Answers  


What is t sql used for?

0 Answers  


What is sql not null constraint?

0 Answers  


why does the selected column have to be in the group by clause or part of an aggregate function? : Sql dba

0 Answers  


what are the advantages of cursors than procedures?

2 Answers  


What is the meaning of disabling a trigger?

0 Answers  


Why do we use subquery?

0 Answers  


Categories