+ 2

how to retrieve last 5 records from table??

16th Jul 2016, 3:53 AM
Ruby Srivastava
Ruby Srivastava - avatar
2 Answers
+ 5
select top 5 * from mytable order by 1 desc (or any increment or any unique data column if u have primary key with increment use it in order by ) it will work . SQL will first order the record in descending manner and top 5 will retrieve top 5 records(for you last 5) I hope this satisfy
16th Jul 2016, 4:41 AM
ashwath nm
ashwath nm - avatar
+ 1
otherwise rank the data.. sort it in descending order and then take top5
16th Jul 2016, 7:02 AM
Tijo Joseph
Tijo Joseph - avatar