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

9. Write a query to list a new column with the difference in temp of the cities Delhi and Mumbai, Mumbai and Jammu and soon. Consider the following table : City_id City Temp. 1 delhi 40 2 Mumbai 35 3 Jammu 32 4 Pune 18

2 Answers  


Explain the characteristics of a transaction server for example atomicity, consistency, isolation, durability?

0 Answers  


How to list all user names in a database?

0 Answers  


Do you think BCNF is better than 2NF & 3NF? Why?

0 Answers   Ernst Young,


Why we need sql server?

0 Answers  






In which files does sql server actually store data?

0 Answers  


What are the grouping functions?

0 Answers  


What is the fastest way to permanently delete a 1 million row table named customers?

0 Answers  


Define constraints and give an example of their use?

0 Answers  


What are the character string functions supported by sql server 2005?

0 Answers  


what are the joins,primary key,foriegn key, candidate key, super key and expain them?

6 Answers   Polaris,


Explain the working of sql privileges?

0 Answers  


Categories