View Single Post
  #17 (permalink)  
Old 11-27-2007, 11:55 AM
narayana
 
Posts: n/a
Default ANY answer. Re: How to find second highest value of a column in a table?

Correlated query:

1.[sql]select sal from emp e where 1=(select count(distinct(sal)) from emp where e.sal<sal);[/sql]
this gives the exact second heighest value

2.[sql]select sal from emp e where &(n-1)=(select count(distinct(sal)) from emp where e.sal<sal);[/sql]

this gives the nth heighest value from atable


k.lakshmi_narayana@yahoo.co.in
Reply With Quote