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 is a corelated subquerry?

738


What are union and union all?

625


How do I change the column size in db2?

709


Why select is not preferred in embedded sql programs?

816


What is the difference between using bind () and rebind () methods of naming class?

908






Give the name of some fields form sqlca.

700


Why db2 is called db2?

671


What is the meaning concurrency in the db2 database?

735


What are the full forms of spufi and dclgen and why are they used?

734


What are the uses of db2 optimizer?

916


What is the use of commit in db2?

708


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

705


What is a db2 package?

681


How can you validate Sql errors during cursor operation in db2 pgms and where do you code?

1814


What is multi row fetch in db2?

677