Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

ISRO | ISRO CS 2017 | Question 11

  • Last Updated : 16 Mar, 2018

Consider the schema
Sailors(sid, sname, rating, age) with the following data

sidsnameratingage
22Dustin745
29Borg133
31Pathy855
32Robert825
58Raghu1017
64Herald735
71Vishnu1016
74King935
85Archer326
84Bob364
96Flinch317

For the query

SELECT S.rating, AVG(S.age) AS avgage FROM Sailors S
Where S.age >= 18
GROUP BY S.rating
HAVING 1 < (SELECT COUNT(*) FROM Sailors S2 where S.rating = S2.rating)

The number of rows returned is
(A) 6
(B) 5
(C) 4
(D) 3


Answer: (D)

Explanation: The qiven query would run like:
First of all where statement would be executed and all the tuples with age less than 18 would be eliminated.
Now with Group By the remaining tuples will be grouped according to rating:

ratingsidsnameage
129Borg33
385Archer26
84Bob64
722Dustin45
64Herald35
831Pathy55
32Robert25
974King35

After this, all the group-by tuples having their count more than 1 will be selected and their ratings and average age will be given as output.

ratingavgage
345
740
840

So, the correct answer is (C)


Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!