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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 need help on SQL query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-08-31 : 10:31:17
vijay writes "Hi sql team,
i am vijay khambe.
i have one qustion.
i want to get the row number from the result set,how can i do this.
i.e. if there are 10 records in the table i want to select 5th record or i want to find the 5th max salary from employee table.

please reply me.
vijay."

nr
SQLTeam MVY

12543 Posts

Posted - 2006-08-31 : 10:33:25
v2000 or v2005?

select top 1 *
from (select top 5 * from tbl order by salary desc) a
order by salary


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-08-31 : 11:54:54
Select min(sal) from
(
Select top 5 sal from table order by sal desc
) T

Also do a google search on Find Nth Maximum

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -