0

This is the question:

Create a query to list all the employees who joined this organization before any clerks were hired and who earn more than any manager.

This is what I have so far:

select ename
from emp
where hiredate<any(select hiredate from emp
where job='CLERK')
and job!='CLERK'
and sal>any(select sal from emp
where empno=super);

-But one of the employees don't have a supervisor (which is null) so it doesn't show any of the employees.

1 Answer 1

1

Something like this?

SELECT ename
FROM   emp
WHERE  hiredate < ANY (
           SELECT hiredate
           FROM   emp
           WHERE  job = 'CLERK'
       )
   AND job <> 'CLERK'
   AND sal > ANY (
           SELECT sal
           FROM   emp
           WHERE  empno IN (
                      SELECT super
                      FROM   emp
                      WHERE  super IS NOT NULL
                  )
           );

Is it a homework? If yes, should be labelled as such.

Sign up to request clarification or add additional context in comments.

1 Comment

it's a practice question not homework... But thanks yes that's what i was looking for! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.