Find the cities name with the condition and temperature from table 'whether' where condition = sunny or cloudy but temperature >= 60.

Category: SQLFind the cities name with the condition and temperature from table 'whether' where condition = sunny or cloudy but temperature >= 60.
Editor">Editor Staff asked 2 years ago

Find the cities name with the condition and temperature from table ‘whether’ where condition = sunny or cloudy but temperature >= 60.

  1. SELECT city, temperature, condition FROM weather WHERE condition = ‘cloudy’ AND condition = ‘sunny’ OR temperature >= 60
  2. SELECT city, temperature, condition FROM weather WHERE condition = ‘cloudy’ OR condition = ‘sunny’ OR temperature >= 60
  3. SELECT city, temperature, condition FROM weather WHERE condition = ‘sunny’ OR condition = ‘cloudy’ AND temperature >= 60
  4. SELECT city, temperature, condition FROM weather WHERE condition = ‘sunny’ AND condition = ‘cloudy’ AND temperature >= 60
1 Answers
Editor">Editor Staff answered 2 years ago

Answer: 3
SELECT city, temperature, condition FROM weather WHERE condition = ‘sunny’ OR condition = ‘cloudy’ AND temperature >= 60
Explanation: We know that the AND operator gives the output only when both the first conditions are true. In contrast, the OR operator gives the output when either the first condition OR the second condition is true. Hence the option C is the correct choice.