Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JDBC and Relational Databases
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Paul Clapham
Devaka Cooray
Liutauras Vilda
Sheriffs:
Jeanne Boyarsky
paul wheaton
Henry Wong
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Tim Moores
Carey Brown
Mikalai Zaikin
Bartenders:
Lou Hamers
Piet Souris
Frits Walraven
Forum:
JDBC and Relational Databases
Get Maximum sal from emp table
Arjun Palanichamy
Ranch Hand
Posts: 51
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi All..
How to get second maximum sal from emp table... for example
emp sal
=== ====
10 4000
20 1000
30 5000
40 9000
50 6000
from this table i want to get the second maximum sal example data : 50 6000, can you reply anybody...
============================================================================
Thanks in Advance
P.Arjun
Martin Simons
Ranch Hand
Posts: 196
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
order by salary and take the second record (or to be exact cycle through the results after the order by and take the second unique value, in order to avoid the first value appearing multiple times).
Perumal Kasi
Greenhorn
Posts: 12
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
select max(sal) from emp a where 2=(select count(distinct(sal)) from emp b
where a.sal<=b.sal);
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
SQL query help
find second largest value in a column
How to get top 3 earners in emp table of SCOTT's schema using SQL
second highest value
inner / sub / inline query
More...