Examveda
Examveda

Find the name of those cities with temperature and condition whose condition is either sunny or cloudy but temperature must be greater than 70oF.

A. SELECT city, temperature, condition FROM weather WHERE condition = 'sunny' AND condition = 'cloudy' OR temperature > 70;

B. SELECT city, temperature, condition FROM weather WHERE condition = 'sunny' OR condition = 'cloudy' OR temperature > 70;

C. SELECT city, temperature, condition FROM weather WHERE condition = 'sunny' OR condition = 'cloudy' AND temperature > 70;

D. SELECT city, temperature, condition FROM weather WHERE condition = 'sunny' AND condition = 'cloudy' AND temperature > 70;

Answer: Option C

Solution(By Examveda Team)

This SQL query is used to retrieve the names of cities along with their temperature and condition, but with specific conditions:

1. WHERE condition = 'sunny' OR condition = 'cloudy': This part of the query specifies that the "condition" in the "weather" table should be either "sunny" or "cloudy." Using the OR operator, it allows the condition to match either of these values.

2. AND temperature > 70: After specifying the condition, this part of the query checks that the temperature is greater than 70°F. The AND operator is used to ensure that this temperature condition is met in addition to the "sunny" or "cloudy" condition.

By combining these conditions, Option C correctly finds cities where the condition is either "sunny" or "cloudy" and the temperature exceeds 70°F. This results in a list of cities that meet both of these criteria.

This Question Belongs to SQL >> Sql Miscellaneous

Join The Discussion

Comments ( 1 )

  1. Akshay Kumar
    Akshay Kumar :
    5 years ago

    None of the answers is correct.

    SELECT city, temperature, condition FROM weather WHERE (condition = 'sunny' OR condition = 'cloudy') AND temperature > 70;

Related Questions on Sql Miscellaneous