Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get the value before max( )

Status
Not open for further replies.

rk68

Programmer
Jul 15, 2003
171
IN
How do I get the value before the max value.
If I say select max(srno) from table, I get certain value.
Now I need to know the value before the max(srno).
How can I do this using Oracle Pl/Sql ? Is there any
function available ?

TIA

Raj
 
In SQL (scott/tiger);

SELECT sal
FROM (SELECT sal
FROM (SELECT sal FROM emp ORDER BY 1 DESC)
WHERE rownum < 3
ORDER BY 1)
WHERE rownum < 2

in PL/SQL you can use SELECT INTO ...

Timo
 
or
Code:
select max(col)
from tbl
where col < (
  select max(col)
  from tbl
)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top