Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-08-25 : 18:59:09
|
srinivasan A.K writes "1. i want to find out the 5 th row in a table. what is the qurey for that2. i want to select 5 th highest salary in a salary table. what is the query for thatthankssrinivasan " |
|
|
chadmat
The Chadinator
1974 Posts |
Posted - 2004-08-25 : 19:16:49
|
| USE NorthwindGOselect min(EmployeeID) from (select top 5 Employeeid from employees order by EmployeeID desc) a-Chadhttp://www.clrsoft.comSoftware built for the Common Language Runtime. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-08-26 : 04:34:36
|
| 5th highest salary:declare @n intset @n = 5 -- number of highest salary to getSelect * From Employee E1 Where (@n-1) = (Select Count(Distinct(E2.Salary)) From Employee E2 Where E2.Salary > E1.Salary)same can be also used for 5th row. but 5th row is a relative term. it depends on your order by column, becasuse there is no order as such in the way the data is stored in sql serverGo with the flow & have fun! Else fight the flow :) |
 |
|
|
|
|
|