How to select nth record from a table?

Answers were Sorted based on User's Feedback



How to select nth record from a table?..

Answer / ravinder pawar

Hi Frnds,
Pravin's logic is correct. I am just modifying it little
bit.

Select Top 1 *
From (Select Top 5 *
from HumanResources.Employee
order by EmployeeID desc)as temp

---Note If we don't use temp we'll get error as mentioned
below:
Incorrect syntax near ')'.

Is This Answer Correct ?    0 Yes 2 No

How to select nth record from a table?..

Answer / pravin s. ahire

Select Top 1 *
From (Select Top N * from tablename order by
table.ColumnName desc)

-- where N = nth record

Is This Answer Correct ?    0 Yes 3 No

How to select nth record from a table?..

Answer / sajida

--For ex in dept table to select 5th record. Instead of
this you can use &n so that it can ask row number

select rnum, d.* from dept d, (select rownum rnum ,
deptno from dept ) e
where d.deptno = e.deptno and rnum = 5

Is This Answer Correct ?    5 Yes 10 No

Post New Answer

More SQL Server Interview Questions

What is an execution plan? When would you use it? How would you view the execution plan?

1 Answers  


What are the differences between triggers and stored procedures?

0 Answers  


How to work on DTS?what is the main requirement?

1 Answers   Getit, ivan,


How to create a testing table with test data in ms sql server?

0 Answers  


You want to implement the one-to-many relationship while designing tables. How would you do it?

0 Answers  






What are the properties of the transactions?

0 Answers  


How many index can be created for single table

4 Answers   CarrizalSoft Technologies, Verizon,


What are database states in ms sql server?

0 Answers  


What is Dependency Injection and provide example?

0 Answers  


Suppose i have a table that contains 5 columns like col1,col2...colm5.I want to import only two column through BCP utility.How to do same through BCP in sybase.

0 Answers   HCL,


You notice that the transaction log on one of your databases is over 4gb the size of the data file is 2mb what could cause this situation, and how can you fix it?

0 Answers  


what is checksum in sql server.........???

0 Answers   TCS,


Categories