一.SELECT from WORLD
8.Exclusive OR (XOR). Show the countries that are big by area or big by population but not both. Show name, population and area.
SELECT name,population,area FROM world
WHERE area>3000000 XOR population>250000000
9.For South America show population in millions and GDP in billions both to 2 decimal places.
SELECT name,round(population/1000000,2) as population,round(gdp/1000000000,2) as gdp FROM world
WHERE continent='South America'
10.Show per-capita GDP for the trillion dollar countries to the nearest $1000.
SELECT name,round(gdp/population,-3) FROM world
WHERE gdp>=1000000000000
11.Show the name and capital where the name and the capital have the same number of characters.
SELECT name,capital FROM world
WHERE LENGTH(name)=LENGTH(capital)
12.Show the name and the capital where the first letters of each match. Don't include countries where the name and the capital are the same word.
SELECT name,capital FROM world
WHERE LEFT(name,1)=LEFT(capital,1)
AND name<>capital
13.
Equatorial Guinea and Dominican Republic have all of the vowels (a e i o u) in the name. They don't count because they have more than one word in the name.
Find the country that has all the vowels and no spaces in its name.
SELECT name FROM world WHERE name like '%a%' and name like'%e%' and name like '%i%' and name LIKE '%o%' and name LIKE '%u%' AND name NOT LIKE '% %'
二.SELECT from Nobel
10.Show year, subject, and name of people who won a 'Medicine' prize in an early year (before 1910, not including 1910) together with winners of a 'Literature' prize in a later year (after 2004, including 2004)
select yr,subject,winner from nobel
where (subject='Medicine' and yr<1910)
or (subject='Literature' and yr>=2004)
12.Find all details of the prize won by EUGENE O'NEILL
select * from nobel
where winner='EUGENE O''NEILL'
14.
The expression subject IN ('Chemistry','Physics') can be used as a value - it will be 0 or 1.
Show the 1984 winners and subject ordered by subject and winner name; but list Chemistry and Physics last.
SELECT winner, subject
FROM nobel
WHERE yr=1984
ORDER BY subject IN ('Physics','Chemistry'),subject,winner