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"?
- A.
Only query 1
- B.
Only query 2
- C.
Both query 1 and query 2
- D.
None of the above
Attempted by 114 students.
Sign up free to check your answer
Sign up freeLoading lesson…

