Consider the following relations and SQL queries given below: Sailors (sid,…

Consider the following relations and SQL queries given below:

Sailors (sid, name, rating, age)

Query 1:

SELECT S.name FROM Sailors S

WHERE NOT EXISTS (SELECT * FROM Sailors S₂ WHERE S₂.age < 22 AND S.rating <= S₂.rating)

Query 2:

SELECT S.name FROM Sailors S WHERE S.rating > ANY (SELECT S₂.rating FROM Sailors S₂ WHERE S₂.age < 22)

Which of the above query is correct implementation of "Find the names of sailors with a higher rating than all sailors with age < 22"?

  1. A.

    Only query 1

  2. B.

    Only query 2

  3. C.

    Both query 1 and query 2

  4. D.

    None of the above

Attempted by 114 students.

Sign up free to check your answer

Sign up free

Explore the full course: Isro

Loading lesson…