95 views

Here query is not correct if there are two persons with higher rating?Am I correct?

| 95 views
0
I think query 1 is correct while query 2 is incorrect?
0
If rating are distinct correct but when rating are same ?? For Example highest rating is 4 and if two persons have rating 4 then will it work??
0
yes it will work, take all the ratings of all the sailors of   age < 21. if the rating of a person is greater than all the ratings of the selected sailors in the  nested subquery, subquery will return NULL and then person will be selected.
0
S.Name rating Age

Nag        4        20

Sree      4         18

Suma     4        16

What will be the output for this table using query 1??

Sorry I didn't get clearly.So trying to understand.
0

regarding this table, no sailor's age os 21, hence subquery returns empty for all records, hence all be selected in the final output.note that NOT EXISTS returns True if the subquery returns empty result.

0
Age is less than 21 that condition will be true for all people they asked less than not equal to 21
0
Null (0 tuples)
0
sorry, yes age is < 21, result should contain Null as no rating is greater than all ratings, query still working correctly.
0
Ok got it so if there are more than one with higher rating it should return null.I thought it should return all people with higher rating and thought query is wrong.Thank you
0
see, ratings of people under age 21 are 45, 50, and 56 for example, there are two people whose ratings are 60, both will be selected using first query.

instead of trying a query on random data, try to understand the logic how a query is working.
0
query in the last table returned null because age of all people were < 21.
0
@manu sir

In the question, it is given "names of sailors". Shouldn't that allow the sailors to be more than 1 (equality allowed?)
+1

Query one is correct.

what will be the output?

sailors

sid    sage srating

a5     20     5

a2     19     4

a1     18     3

I think answer should be null even a5 has rating higher than all sailors with age<21 according to querry 1. INCORRECT QUERRY 1???
by (345 points)