select deptno, ename, sal
from emp e1
where
(
select count(*)
from emp e2
where e2.deptno=e1.deptno and e2.sal<e1.sal
) <2
order by deptno, sal;
select deptno, ename, sal
from emp e1
where
(
select count(*)
from emp e2
where e2.deptno=e1.deptno and e2.sal<e1.sal
) <2
order by deptno, sal;