Consider the table employee(empId, name, department, salary) and the two queries Q1 ,Q2 below. Assuming that department 5 has more than one employee, and we want to find the employees who get higher salary than anyone in the department 5, which one of the statements is TRUE for any arbitrary employee table?

Q1 :

Select e.empId

    From employee e
 Where not exists
    (Select * From employee s where s.department = “5” and 
                                    s.salary >=e.salary)

Select e.empId

 From employee e
 Where e.salary > Any
(Select distinct salary From employee s Where s.department = “5”)

(A) Q1 is the correct query

(B) Q2 is the correct query

(C) Both Q1 and Q2 produce the same answer.

(D) Neither Q1 nor Q2 is the correct query

My work:- I am stuck at the word "anyone". If by anyone it means that all employees of department 5 than Q1 is correct,but if by anyone it means "any" (at least one) then Q2 is correct.We have a function is SQl named as "any" and that function says at least one should satisfy condition.So i am relating anyone to that function.Please help in understanding it correctly

  • $\begingroup$ The title you have chosen is not well suited to representing your question. Please take some time to improve it; we have collected some advice here. Thank you! $\endgroup$
    – Raphael
    Jul 14, 2017 at 16:47
  • 1
    $\begingroup$ Also, you need to give attribution for the parts you copied! $\endgroup$
    – Raphael
    Jul 14, 2017 at 16:48

1 Answer 1


In English, "higher salary than anyone in department 5" normally means "higher salary than everyone in department 5".


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.