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
Sign In
Register
AdSense Revenue
Active Members
Today
srinivasa reddy...
(17)
Babu Akkandi
(16)
Shashi
(16)
Last 7 Days
Appukuttan
(620)
Babu Akkandi
(453)
Tejinder Singh ...
(275)
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:
Programmer
Member 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 2008
Member 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
Sign In
(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
COUNT(*) VS IF EXIST
working with SELECT
Creating function for Date Difference
How to insert single quote into a column in SQL
How to view the user created tables in SQL Server
dotNet Slackers
BizTalk Adaptors
Web Design
Contact Us
Privacy Policy
Terms Of Use