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
1
6
2
5
3
4
4
3