C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Find Nth Max value in SQL


Posted Date: 28 Aug 2008      Total Responses: 2

Posted By: Navaneetha Krishnan .P.R       Member Level: Gold     Points: 1



Hi all,


I am using SQL 2005 Express, I have a table like this,

Table Name : Employee

Eid Name Salary

1 harry 3500
2 jack 2500
3 john 2500
4 xavier 5500
5 steven 7500
6 susana 2400

I would like to select the nth maximum salary in this table, and suppose if there is 100 records in this table, i want to select 10th maximum salary.

I want the single query answer.(if it is possible)

Can anyone help me?

Thanks in Advance





Responses

Author: Ritesh N. Jain    28 Aug 2008Member Level: GoldRating:     Points: 2

Try this query

SELECT TOP 1 salary
FROM (SELECT TOP 10 salary FROM EmployeeORDER BY salary desc ) Empsalary
Order by salary asc



Author: http://venkattechnicalblog.blogspot.com/    31 Aug 2008Member Level: DiamondRating:     Points: 3



select Eid, name,salary
from
(select row_number() (over salary) as rno,Eid,name,salary from Employee)
t
where rno=10


Regards,
Venkatesan Prabu .J



Post Reply
You must Sign In to post a response.
Next : Sql query need
Previous : Auto Incremet in SQL
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use