This will get you only the second max salary row
[sql]
SELECT * FROM EMP
WHERE SAL IN (SELECT MAX(SAL) FROM EMP
WHERE SAL <> (SELECT MAX(SAL) FROM EMP)) [/sql]
from
how to find second largest number through a query in sql - Community Forums - Developer Fusion, the UK developer community - VB, ASP, C#, .NET, PHP and XML tutorials & source code
[sql]
select * from tmp_table m1
where (n-1)=(select count(distinct(m2.age))
from tmp_table m2 where
m2.age>m1.age)[/sql]