2 votes 2 votes Here query is not correct if there are two persons with higher rating?Am I correct? Niharika 1 asked Jan 16, 2018 Niharika 1 520 views answer comment Share Follow See all 13 Comments See all 13 13 Comments reply Manu Thakur commented Jan 16, 2018 reply Follow Share I think query 1 is correct while query 2 is incorrect? 0 votes 0 votes Niharika 1 commented Jan 16, 2018 reply Follow Share 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 votes 0 votes Manu Thakur commented Jan 16, 2018 reply Follow Share 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 votes 0 votes Niharika 1 commented Jan 16, 2018 reply Follow Share 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 votes 0 votes Manu Thakur commented Jan 16, 2018 reply Follow Share 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 votes 0 votes Niharika 1 commented Jan 16, 2018 reply Follow Share Age is less than 21 that condition will be true for all people they asked less than not equal to 21 0 votes 0 votes thepeeyoosh commented Jan 16, 2018 reply Follow Share Null (0 tuples) 0 votes 0 votes Manu Thakur commented Jan 16, 2018 reply Follow Share sorry, yes age is < 21, result should contain Null as no rating is greater than all ratings, query still working correctly. 0 votes 0 votes Niharika 1 commented Jan 16, 2018 reply Follow Share 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 votes 0 votes Manu Thakur commented Jan 16, 2018 reply Follow Share 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 votes 0 votes Manu Thakur commented Jan 16, 2018 reply Follow Share query in the last table returned null because age of all people were < 21. 0 votes 0 votes srivivek95 commented Jan 16, 2018 reply Follow Share @manu sir In the question, it is given "names of sailors". Shouldn't that allow the sailors to be more than 1 (equality allowed?) 0 votes 0 votes Anu007 commented Jan 16, 2018 reply Follow Share Query one is correct. 1 votes 1 votes Please log in or register to add a comment.
0 votes 0 votes 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??? Rohit Kumar 2 answered Mar 15, 2018 Rohit Kumar 2 comment Share Follow See all 0 reply Please log in or register to add a comment.