Hi, I need to choose empno and the salary of all female workers who have at least two men in their department with the same salary as the woman ..
These are tables
EMP:
empno|ename|deptno|sal|gender
DEPT:
deptno|dname
This is my code, for some reason this associate gives the desired result
SELECT *
FROM EMP E
WHERE E.GENDER = 'F' AND 2 <= (SELECT COUNT(*)
FROM EMP E2
WHERE E2.GENDER = 'M' AND
E2.SAL = E.SAL
AND E.DEPTNO = E2.DEPTNO);
source
share