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...


I have a table which has thousand of records i want to
fetch only record num 100 to record num 200. Write a query
that satisfies this criteria.(Cant use any keys)
Anyone please reply ASAP!

Answers were Sorted based on User's Feedback



I have a table which has thousand of records i want to fetch only record num 100 to record num 200..

Answer / m4io

scrollable cursors
------------------
DECLARE cursor_name sensitivity SCROLL CURSOR FOR
SELECT ... FROM ...

open cursor

FETCH ABSOLUTE 100 FROM cursor_name

do 100 times
FETCH NEXT FROM cursor_name

Is This Answer Correct ?    7 Yes 1 No

I have a table which has thousand of records i want to fetch only record num 100 to record num 200..

Answer / mvramesh

How about combingin two queries with set operator EXCEPT,
if you have query A EXCEPT query B, the result would be A-B.

Select * from table A fetch first 200 rows only
Union except
Select * from table A fetch first 100 rows only

Is This Answer Correct ?    5 Yes 2 No

I have a table which has thousand of records i want to fetch only record num 100 to record num 200..

Answer / sudheer d

YA THE ANSWER IS BY USING CURSORS ONLY
declare
cursor USER_Cursor
is select *
from <table_name>;

y <TABLE_NAME>%ROWTYPE; --ITS A DATA TYPE INCLUDES
WHOLE ROW 4M A TABLE IN TO X
COUNT1 number(2);

begin
COUNT1:=1;
open USER_Cursor;

while USER_Cursor%FOUND AND COUNT1 <>101
loop
fetch USER_Cursor into y;-- JUST FETCH DONT DISPLY -
--TILL 101ST RECORD
COUNT1:=COUNT1+1;
end loop;

--NOW DISPLAY FROM 101 RECORD TO 200 RECORD
while USER_Cursor%FOUND AND COUNT1 <>201
loop
fetch USER_Cursor into y;
dbms_output.put_line(y);
COUNT1:=COUNT1+1;
end loop;

close USER_Cursor;
end;

Is This Answer Correct ?    3 Yes 0 No

I have a table which has thousand of records i want to fetch only record num 100 to record num 200..

Answer / vikatakavi08

select * from emp where rownum<=100 and rownum>=200;

Is This Answer Correct ?    2 Yes 0 No

I have a table which has thousand of records i want to fetch only record num 100 to record num 200..

Answer / sangeeta david

We can make use of Relative record number that is

Select * from Table A where RRN(A) between 100 and 200

Is This Answer Correct ?    3 Yes 2 No

I have a table which has thousand of records i want to fetch only record num 100 to record num 200..

Answer / mysterious

is it row number that u are looking for?

Is This Answer Correct ?    0 Yes 0 No

I have a table which has thousand of records i want to fetch only record num 100 to record num 200..

Answer / prasenjit

Yes and no in both ways.
I know there is a Roid() Over() function DB2 release 7
onwards and that shld solve the problem.
But what if there was condition that you cant use these
functions.
Cant there be any query that can produce the req result.

Is This Answer Correct ?    1 Yes 1 No

I have a table which has thousand of records i want to fetch only record num 100 to record num 200..

Answer / the boss

There is no correct answer to this flawed question.
In RDBMS theory a table doesn't have 'records'; it is an
UNORDERED set of tuples ("rows"), so there is no
recordnumber 100 or 200.

Is This Answer Correct ?    0 Yes 0 No

I have a table which has thousand of records i want to fetch only record num 100 to record num 200..

Answer / venkat

select * from table where empno > 100 or ( select * from
table where empno < 200)

Some many ways to write a query for this, this is one way...

Is This Answer Correct ?    0 Yes 0 No

I have a table which has thousand of records i want to fetch only record num 100 to record num 200..

Answer / rajeshkumar

SELECT * FROM TCB732D.AR_AR WHERE NUM_SEQ_AR IN(
SELECT NUM_SEQ_AR FROM TCB732D.AR_AR ORDER BY NUM_SEQ_AR
FETCH FIRST 200 ROWS ONLY)
ORDER BY NUM_SEQ_AR FETCH FIRST 100 ROWS ONLY

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More DB2 Interview Questions

Can you Average the Characters ?

3 Answers  


Is db2 a programming language?

0 Answers  


How to view db2 table structure?

0 Answers  


How connect db2 database to datastage?

0 Answers  


what is the Foreign key? explain?

2 Answers  


What are the benefits of using the db2 database?

0 Answers  


can you use symbolic parameters in JOB?

5 Answers   IBM,


how to resolve -811 error. give clear explination

4 Answers   IBM,


What is the purpose of rollback and commit?

0 Answers  


How to find the maximum value in a column in the db2 database?

0 Answers  


how to resolve -805. give clear explination for that

2 Answers   IBM,


What is the maximum No of rows per page?

0 Answers   IBM,


Categories