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 db2 stogroup?

881


What is the physical storage length of the data types date, time, and timestamp?

853


What is an instance in db2?

747


Why cursor is used in db2?

759


Mention the way of highlighting as well as putting a cursor to use in a cobol program.

831


What is the use of with ur in db2?

789


What is a dbrm in db2?

741


I have a subprogram B calling from mainprogram A.I have opened a cursor in A ,Can i fetch the same cursor in subprogram B , If yes , Please explain the reason?

2133


What is ibm db2 connect?

742


What is collection in db2 bind?

765


What is the picture clause of null indicator variable?

874


What is bind in db2?

785


What is ibm db2 database?

719


What is meant by explain?

843


Define data page.

804