File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get Maximum sal from emp table

 
Arjun Palanichamy
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic