Change the query shown so that it displays Nobel prizes for 1950.
SELECT yr, subject, winner FROM nobel
WHERE yr =1950
Show who won the 1962 prize for Literature.
SELECT winner FROM nobel
WHERE yr =1962AND subject ='Literature'
Show the year and subject that won ‘Albert Einstein’ his prize.
SELECT yr,subject FROM nobel
WHERE winner='Albert Einstein'
Give the name of the ‘Peace’ winners since the year 2000, including 2000.
SELECT winner FROM nobel
WHERE subject='Peace'and yr>=2000`
Show all details (yr, subject, winner) of the Literature prize winners for 1980 to 1989 inclusive.
SELECT yr, subject, winner FROM nobel
WHERE yr between1980and1989and(subject='Literature')
Show all details of the presidential winners:Theodore Roosevelt,Woodrow Wilson,Jimmy Carter,Barack Obama
SELECT*FROM nobel
WHERE winner in('Theodore Roosevelt','Woodrow Wilson','Jimmy Carter','Barack Obama')
Show the winners with first name John
SELECT winner FROM nobel
WHERE winner like concat ('John','%')
Show the year, subject, and name of Physics winners for 1980 together with the Chemistry winners for 1984.
SELECT yr, subject,winner FROM nobel
WHERE subject='Physics'and yr='1980'or(subject='Chemistry'and yr='1984')
Show the year, subject, and name of winners for 1980 excluding Chemistry and Medicine
SELECT yr, subject,winner FROM nobel
WHERE yr='1980'and(subject!='Chemistry')and(subject!='Medicine')
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))
Find all details of the prize won by PETER GRÜNBERG
SELECT*FROM nobel
WHERE winner='PETER GRÜNBERG'
Find all details of the prize won by EUGENE O’NEILL
SELECT*FROM nobel
WHERE winner='EUGENE O''NEILL' /*使用两个单引号代替一个,为转义字符*/
List the winners, year and subject where the winner starts with Sir. Show the the most recent first, then by name order.
SELECT winner,yr,subject FROM nobel
WHERE winner like'Sir%'ORDERBY yr DESC,winner /*先按年份的降序,再按获奖者的升序*/
Show the 1984 winners and subject ordered by subject and winner name; but list Chemistry and Physics last.
在这里插入代码片
SELECT within SELECT Tutorial
List each country name where the population is larger than that of ‘Russia’.
SELECT name FROM world
WHERE population >(SELECT population FROM world
WHERE name='Russia')
Show the countries in Europe with a per capita GDP greater than ‘United Kingdom’.
SELECT name FROM world
WHERE GDP/population >(SELECT GDP/population FROM world
WHERE name='United Kingdom')and(continent='Europe')
List the name and continent of countries in the continents containing either Argentina or Australia. Order by name of the country.
SELECT name,continent FROM world
WHERE continent in(SELECT continent FROM world
WHERE name in('Argentina','Australia'))ORDERBY name
Which country has a population that is more than Canada but less than Poland? Show the name and the population.
SELECT name,population FROM world
WHERE population>(SELECT population
FROM world
WHERE name ='Canada')and population<(SELECT population FROM world
WHERE name='Poland')
Show the name and the population of each country in Europe. Show the population as a percentage of the population of Germany.
在这里插入代码片
Which countries have a GDP greater than every country in Europe? [Give the name only.] (Some countries may have NULL gdp values)
SELECT name FROM world
WHERE GDP >ALL(SELECT GDP FROM world
WHERE GDP >0and continent='Europe')
Find the largest country (by area) in each continent, show the continent, the name and the area找出各大洲面积最大的国家
/*相关子查询问题*/SELECT continent, name, area FROM world x
WHERE area >=ALL(SELECT area FROM world y
WHERE y.continent=x.continent
AND area>0)
List each continent and the name of the country that comes first alphabetically.
SELECT x.continent,x.name FROM world AS x
WHERE x.name<=ALL(SELECT y.name FROM world AS y WHERE x.continent=y.continent)
Find the continents where all countries have a population <= 25000000. Then find the names of the countries associated with these continents. Show name, continent and population.找出所有国家人口不超过25000000的州
SELECT x.name,x.continent,x.population FROM world AS x
WHERE25000000>=ALL(SELECT population FROM world y
WHERE x.continent=y.continent
AND population>0)
Some countries have populations more than three times that of any of their neighbours (in the same continent). Give the countries and continents.国家的人口多于其邻国(同一州)的三倍
SELECT x.name,x.continent FROM world AS x
WHERE x.population>=ALL(
SELECT from Nobel TutorialChange the query shown so that it displays Nobel prizes for 1950.SELECT yr, subject, winnerFROM nobelWHERE yr = 1950Show who won the 1962 prize for Literature.SELECT winnerFROM nobelWHERE yr = 1962 AND subject = 'L