SQL to retrieve the 5th record only

My Question is :
I have one table , from this table I have 1000 records. Particularly I need retrieve the 5th record only.
no need retrieve 1 to 4th only 5th record only I need retrieve by using SQL Query?

Showing Answers 1 - 9 of 9 Answers

Anthony H.

  • Jun 21st, 2015
 

You can use the SELECT... LIMIT [X] OFFSET [Y] if this is in MySQL. X is the amount of rows you want to return, while Y is the amount of rows to skip.

Code
  1. SELECT * FROM [tbl] LIMIT 1 OFFSET 4

  Was this answer useful?  Yes

pravalika

  • Jul 2nd, 2015
 

Code
  1. WITH CTE

  2. AS

  3. (

  4. SELECT *, Row_number() over (ORDER BY Personid) AS[5th Record] FROM table_name

  5. )

  6. SELECT * FROM CTE WHERE PersonID=5

  Was this answer useful?  Yes

dan

  • Jul 30th, 2015
 

Such requirement is fundamentally incorrect.

Yes, such a need might arise when data from a non-RDBMS source has been imported into a RDBMS. If some one forethought should be given to identifying the rows with a unique row number. It is then a simple matter.

Remember that in a properly designed table the order of rows in a table should have no meaning. Also, the order if columns in a table also should have so significance.

In a table that is designed with RDBMS design principles, such a question would not arise.

Hope this helped.

  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