| 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);
|
 |
 |
|
|
subject: Get Maximum sal from emp table
|
|
|