How do you retrieve the last N records from a table?

Answer Posted / jyoti

We can retrieve last N records using Order by clause in the
query.

The ORDER BY clause using DESC
then give limits 0,N
for ex: SELECT * from table_name OREDER BY id DESC limit 0,10

It will return you last 10 records of the table.

Is This Answer Correct ?    1 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When can we use the where clause and the having clause?

574


What are the basic techniques of indexing?

563


what is the difference between primary key and unique key? : Sql dba

518


What is offset in sql query?

589


what are the differences among rownum, rank and dense_rank? : Sql dba

534






Is inner join faster than left join?

626


How do you rank data in sql?

511


What is flag in sql?

531


what is a table in a database ? : Sql dba

535


what is the difference between blob and text? : Sql dba

519


What is procedure and function in sql?

524


What is the sql case statement?

568


What is pragma in pl sql?

590


Can a varchar be a primary key?

532


What is faster join or subquery?

505