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 !






How to find second largest value from table


Posted Date: 20 May 2008    Resource Type: Code Snippets    Category: SQL
Author: ProgrammerMember Level: Gold    
Rating: Points: 10



The following SQL query shows how to find second largest value from table.


Select max(salary) from emp where salary
not in (select max(salary) from emp)


In the above query,the sub query executes first.It finds the largest value from the table.When the main query executes, it considers all the values excluding the value searched by sub query.




Responses

Author: mahesh sheka    21 May 2008Member Level: Bronze   Points : 2
An alternative SQL Query to find out the second largest value in table.


SELECT MIN(Salary) FROM
(
SELECT TOP 2 Salary FROM Emp (NOLOCK)
ORDER BY Salary DESC
)AS Temp



Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to use stored procedure to take large Text input and populate in a table
Previous Resource: How to save point in transactions of Database
Return to Discussion Resource Index
Post New Resource
Category: SQL


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use