Vijay
Vijay

Reputation: 8461

how to get specific number of row data in SQL Server 2005

my table look like

ID      Name       TakenDateTime
2   critical care   19-Dec-12 11:04:45 AM
3   Pathology       26-Dec-12 5:59:28 PM
4   Radiology       05-Jan-13 7:20:56 PM
5   Cardiology      07-Jan-13 3:54:04 PM
6   Neurology       07-Jan-13 3:56:13 PM
7   Oncology        07-Jan-13 3:56:19 PM
9   Orthopedic      08-Jan-13 5:30:29 PM
10  Cardiothoracic  08-Jan-13 5:30:52 PM

from this table i just want 5th number of row data in SQL Server 2005. is it possible if yes then please provide me possible way for that. Any help will be appreciate...

Upvotes: 0

Views: 1333

Answers (1)

Amit Singh
Amit Singh

Reputation: 8129

SELECT
  ID,
  Name,
  TakenDateTime
FROM (SELECT
  ROW_NUMBER() OVER (ORDER BY Id) AS Row,
  *
FROM TableName)
t
WHERE t.Row = 5

Sql Fiddle Demo

Upvotes: 5

Related Questions