ash, this is the sql forum
if you want oracle, please post in the oracle forum
let's have standard sql solutions, please
Code:
select X.eno
, X.ename
, X.sal
from emp X
left outer
join emp Y
on Y.sal > X.sal
group
by X.eno
, X.ename
, X.sal
having count(*) < 2
union all
select X.eno
, X.ename
, X.sal
from emp X
left outer
join emp Y
on Y.sal < X.sal
group
by X.eno
, X.ename
, X.sal
having count(*) < 3