Examveda
Examveda

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');

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(By Examveda Team)

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.

This Question Belongs to SQL >> Sql Miscellaneous

Join The Discussion

Comments ( 11 )

  1. Manikanta Simal
    Manikanta Simal :
    2 years ago

    option A is correct because city is not mention in question

  2. Naveena Jakka
    Naveena Jakka :
    2 years ago

    Option A is also valid...

  3. Rafi Ullah
    Rafi Ullah :
    3 years ago

    You just replace City with country in syntax, simple.

  4. Ahmed Raafat
    Ahmed Raafat :
    3 years ago

    option A is also valid because it wasn't mentioned in the question that the 'condition' column is existed in another table!

  5. Ahmed Raafat
    Ahmed Raafat :
    3 years ago

    option A is also valid because it wasn't mentioned in the question that the 'condition' column is existed in another table!

  6. Muhammad Najam-us-saqib
    Muhammad Najam-us-saqib :
    4 years ago

    Option B is invalid as the question asks for the names of all the countries, not cities

  7. Yogita Chawariya
    Yogita Chawariya :
    7 years ago

    option A is also valid as city is not mentioned any where in the question.

  8. Yogita Chawariya
    Yogita Chawariya :
    7 years ago

    option A is all valid as city is not mentioned any where in the question.

  9. Ganesh Apune
    Ganesh Apune :
    7 years ago

    The option b is the wrong answer because the in this condition written as = sunny'

  10. Manzar Iqbal
    Manzar Iqbal :
    7 years ago

    Here it is no specified that the condition can be found from cities only. Hence the first option is simple and correct in my opinion.

  11. Sakshi Maheshwari
    Sakshi Maheshwari :
    8 years ago

    i think option one is right bcoz the query says the country condition should be sunny ..it doesn't ask to check for city condition..
    or on the other way aroud i think this is an ambiguous query.

Related Questions on Sql Miscellaneous