Consider the following schema: Sailors(sid: int...

Consider the following schema:

Sailors(sid: integer, sname: string, rating: integer, age: real)

Consider the following query:
Find the names of sailors with a higher rating than all sailors with age < 21.
Which of the following SQL queries will obtain the correct answer to this question.

  1. SELECT S.sname
    FROM Sailors S
    WHERE NOT EXISTS ( SELECT * 
                       FROM Sailors S2
                       WHERE S2.age < 21 AND S.rating <= S2.rating)
  2. SELECT S.sname
    FROM Sailors S
    WHERE S.rating > ANY ( SELECT S2.rating
                           FROM Sailors S2
                           WHERE S2.age < 21)

1 only

2 only

both

none

Hint: 

<div class="tex2jax"></div>

0Comment