aspose file tools*
The moose likes JDBC and the fly likes Get Maximum sal from emp table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Get Maximum sal from emp table" Watch "Get Maximum sal from emp table" New topic
Author

Get Maximum sal from emp table

Arjun Palanichamy
Ranch Hand

Joined: Jul 15, 2006
Posts: 51
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

Joined: Mar 02, 2006
Posts: 196
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

Joined: Jul 10, 2004
Posts: 12
select max(sal) from emp a where 2=(select count(distinct(sal)) from emp b
where a.sal<=b.sal);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Get Maximum sal from emp table