47redlands
Programmer
Novice to SQL need to help with coding
I have a population table and I want search the countries that are big by area or big by population.
select name, population, area from worldwhere population >250000000 or area > 3000000
The above SQL code does this, however I only wish to Show the countries that are big by area or big by population but not both.
so for example the search returns the following:
name population area
Australia 23545500 7692024
Brazil 202794000 8515767
Canada 35427524 9984670
China 1365370000 9596961
India 1246160000 3166414
Indonesia 252164800 1904569
Russia 146000000 17125242
United States 318320000 9826675
India, USA and China have both high population and big area so should not be in the results. How can I do this?
I have tried this but I think my logic is wrong?
select name, population, area from worldwhere population >250000000 or area > 3000000 and name Not IN ('USA', 'China', 'India');
I have a population table and I want search the countries that are big by area or big by population.
select name, population, area from worldwhere population >250000000 or area > 3000000
The above SQL code does this, however I only wish to Show the countries that are big by area or big by population but not both.
so for example the search returns the following:
name population area
Australia 23545500 7692024
Brazil 202794000 8515767
Canada 35427524 9984670
China 1365370000 9596961
India 1246160000 3166414
Indonesia 252164800 1904569
Russia 146000000 17125242
United States 318320000 9826675
India, USA and China have both high population and big area so should not be in the results. How can I do this?
I have tried this but I think my logic is wrong?
select name, population, area from worldwhere population >250000000 or area > 3000000 and name Not IN ('USA', 'China', 'India');