How will fetch last 5 rows from table in db2

Answer Posted / vaneeshh khurana

See there is no direct method to do so, but still if we want
last 5 rows only we can create a logic which is as follows.

1. Declare an array to save the fetch rows with occurs of 5.
2. Now fetch the rows and start saving in that array such
that when the count becomes 5 overwrite the 6th fetch in the
first occurs similarly the 7th fetch on the 2nd occur.
3. Now when all the fetching is done the array will contains
the last 5 fetched rows.

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Mention the various locks that are available in db2.

774


How do you stop a db2 database in linux?

741


How to fetch the last row from the table in SQL (db2)?

1302


What is bind plan?

796


Hi, i would like to start a new carrier in DB2 DBA.Which and what all step should i have to take..?

2897


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

831


What do you mean by between and in? Is between inclusive of specified range values?

865


What is the default page size of buffer pools?

854


What is check constraint. Explain with example.

840


How do I optimize a query in db2?

818


How to view db2 table structure?

790


Is ibm db2 open source?

802


Why select is not preferred in embedded sql programs?

924


How do I add a column in db2?

773


What is the result of open cursor statement?

817