I am stuck on Q.8 on this tutorial which is a followup to Q.7:
Question #7
Two ways to be big: A country is big if it has an area of more than 3 million sq km or it has a population of more than 250 million.
Show the countries that are big by area or big by population. Show name, population and area.
Question #8
USA and China are big in population and big by area. Exclude these countries.
Show the countries that are big by area or big by population but not both. Show name, population and area.
The code I have had some success with is:
SELECT name, population, area
FROM world
WHERE area > 3000000
OR population > 250000000
AND NOT EXISTS (
SELECT name, population, area
FROM world
WHERE name='USA'
OR 'China'
)
but 'China' and 'USA' still appear in my results! Can someone show me how to write a WHERE clause to remove them?
Aucun commentaire:
Enregistrer un commentaire