Vidyalelo
SQL · Q41

SQL

Programming · SQL · question 41

Q41

Which of the following query finds the total rating of the sailors who have reserved boat "103"?

A.
SELECT SUM(s.rating) FROM sailors s, reserves r AND r.bid = 103;
B.
SELECT s.rating FROM sailors s, reserves r WHERE s.sid = r.sid AND r.bid = 103
C.
SELECT COUNT(s.rating) FROM sailors s, reserves r WHERE s.sid = r.sid AND r.bid = 103
D.
SELECT SUM(s.rating) FROM sailors s, reserves r WHERE s.sid = r.sid AND r.bid = 103
Answer

Answer: Option D

Solution

Answer: Option D
Solution:
To find the total rating of the sailors who have reserved boat "103," you should use the SQL query SELECT SUM(s.rating) FROM sailors s, reserves r WHERE s.sid = r.sid AND r.bid = 103; (Option D). This query correctly joins the "sailors" and "reserves" tables on the sailor ID (s.sid) and specifies the boat ID (r.bid) to be "103." It then calculates the sum of the ratings (s.rating) of the sailors who have reserved this boat. Option D is the correct choice for achieving this result.