How will fetch last 5 rows from table in db2

Answer Posted / sree

SELECT * FROM TABLENAME ORDER BY PRIMARYCOLUMNNAME DESC
FETCH FIRST 5 ROWS ONLY ;

THIS ANSWER IS VALID ONLY IF THERE IS A PRIMARY KEY
COLUMN,OTHERWISE IT WONT WORK

IF THERE IS NO PRIMARY KEY COLUMN IN GIVEN TABLE ,I DON'T
KNOW THE ANSWER

FOR FETCHING FIRST 5 ROWS

SELECT * FROM TABLENAME FETCH FIRST 5 ROWS ONLY;

Is This Answer Correct ?    8 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What happens in bind step in a db2 program?

565


Mention some fields that are a part of sqlca.

600


What is a storage group (stogroup)?

774


What is query_cache_limit?

541


What are the rules for db2 programming?

641






What is phantom read in db2?

636


i want to maintain uniqueness on pdf without make lf??????????

1633


Comment whether dclgen is mandatorily used. If not, then what is the point of using it?

608


Explain various types of locks in db2?

689


What is the difference between bind and rebind in db2?

848


Explain db2.

612


What is isolation level in db2?

577


What is the cobol picture clause of the db2 data types date, time, timestamp?

615


What is the use of commit in db2?

628


What is null value in db2?

563