Vidyalelo
SQL · Q34

SQL

Programming · SQL · question 34

Q34

Find the names of the countries whose condition is sunny.

A.
SELECT country FROM location WHERE condition = 'sunny';
B.
SELECT country FROM location WHERE city IN (SELECT city FROM weather WHERE condition = 'sunny');
Answer
C.
SELECT country FROM location WHERE city NOT IN (SELECT city FROM weather WHERE condition = 'sunny');
D.
SELECT country FROM location WHERE city UNION (SELECT city FROM weather WHERE condition = 'sunny');

Answer: Option B

Solution

Answer: Option B
Solution:
To find the names of countries where the condition is "sunny," you should use the SQL query SELECT country FROM location WHERE city IN (SELECT city FROM weather WHERE condition = 'sunny'); (Option B). This query correctly uses a subquery to first select the cities with a "sunny" condition from the "weather" table and then matches those cities to the "city" column in the "location" table to determine the corresponding countries. Option B is the appropriate choice for obtaining the desired result.