Consider the schema Sailors(sid, sname, rating, age) with the following data Sid Sname Rating age 22 Dustin 7 45 29 Borg 1 33 31 Pathy 8 55 32 Robert 8 25 58 Raghu 10 17 64 Herald 7 35 71 Vishnu 10 16 74 King 9 35 85 Archer 3 26 84 Bob 3 64 96 Flinch 3 17 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

Consider the schema Sailors(sid, sname, rating, age) with the following data Sid Sname Rating age 22 Dustin 7 45 29 Borg 1 33 31 Pathy 8 55 32 Robert 8 25 58 Raghu 10 17 64 Herald 7 35 71 Vishnu 10 16 74 King 9 35 85 Archer 3 26 84 Bob 3 64 96 Flinch 3 17 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 Correct Answer 3

Without "having" clause query calculates the average age (where age >= 18) and groups by ratings so table returned is:

Rating Average
1 33
3 45
7 40
8 40
9 35

After applying "having" clause table returned is:

Rating Average
3 45
7 40
8 40

Related Questions

Consider the following relation schema Sailors(sid, sname, rating, age) Reserve(sid, bid, day) Boats(bid, bname, color) What is the equivalent of following relational algebra query in SQL query. πsname((σcolor= ‘red’Boats) ⨝ Reserves ⨝ Sailors)