How do you display last 5 records in DB2?

Questions by chhavis928   answers by chhavis928

Showing Answers 1 - 7 of 7 Answers

Baurisetty Dhiraj

  • Aug 28th, 2011
 

select * from (select * from (select * from table_name order by rowid desc) where rownum<=5) order by rownum desc

  Was this answer useful?  Yes

satyanarayana

  • Jan 17th, 2012
 

First sort the records by using order by clause and then issue the following query

Code
  1.  


Then it will give the last five records of the table

  Was this answer useful?  Yes

Mohit

  • May 28th, 2012
 

There is nothing called "fetch last n records only" in db2...

You can use select col1 from table1 order by col1 desc fetch first 5 records only

  Was this answer useful?  Yes

madhavan

  • Mar 10th, 2014
 

SELECT * FROM Table_Name order by column_name desc Fetch first 5 rows only;

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions