38、SQLZOO 之 SELECT from Nobel Tutorial

38, SQLZOO of SELECT from Nobel Tutorial exercises answer
https://sqlzoo.net

nobel Nobel Prize winners
we continue to practice simple single-table SQL query. This tutorial is about Nobel Prize winners:
nobel (YR, Subject, Winner)
Here Insert Picture Description
1. Change the query to display the 1950 Nobel prize information.
select yr, subject, winner from nobel where yr = '1950'

2. show who won the 1962 Prize for Literature (Literature).
select winner from nobel where subject = ' Literature'and yr =' 1962 '

3. Display "Einstein" ( 'Albert Einstein') of the year award and awards.
select yr, subject from nobel where winner = 'Albert Einstein'

4. Display ( 'Peace') winners in 2000 and later Peace Prize.
select winner from nobel where yr> = '2000'and subject =' peace '

5. show from 1980 to 1989 (inclusive included) literary prize (Literature) winner all the details (of the theme, the winners).
select yr, subject, winner from nobel where yr between 1980 and 1989 and subject = 'Literature'

6. display all details of the president's winners: • Theodore Roosevelt Theodore Roosevelt, Woodrow Wilson • Woodrow Wilson, Jimmy Carter • Carter Jimmy
the SELECT * from nobel Winner in the WHERE ( 'Theodore Roosevelt', 'Woodrow Wilson', 'Jimmy carter ')

7. Display name for John the winners. (Note: foreigners name (First name) first, Surname (Last name) after)
the SELECT Winner Winner from the WHERE nobel like 'John%'

8. Display 1980 physics (physics) winners, and the 1984 Prize in Chemistry (chemistry) winner.
select yr, subject, winner from nobel where (yr = '1980' and subject = 'physics') or (yr = '1984' and subject = 'chemistry')

9. View the 1980 winners, but excluding Prize in Chemistry (Chemistry) and the Prize for Medicine (Medicine).
select yr, subject, winner from nobel where yr = '1980' and subject not in ( 'Chemistry', 'Medicine')

10. The display early Prize in Medicine (Medicine) Winner (before 1910, excluding 1910), and in recent years Prize in Literature (Literature) winner (after 2004, including in 2004).
select yr, subject, winner from nobel where (yr < '1910' and subject = 'Medicine') or (yr> = '2004' and subject = 'Literature')

11.Find all details of the prize won by PETER GRÜNBERG
select * from nobel where winner =‘PETER GRÜNBERG’

12. • Find Eugene O'Neill EUGENE O'NEILL winning all the details Find all details of the prize won by EUGENE O'NEILL
[escape character - a single quote: You can not put a single quotation mark directly on the string. However, you can use two single quotation marks as a single quotation mark in the string. ]
Select * from nobel where winner = ' EUGENE O''NEILL'

13. Knight lined Knights in order
listed Jazz winners, year, prize page (Lord's name begins with Sir). First display the latest winners, and then press the name of the same year arrangement order.
select winner, yr, subject from nobel where winner like 'Sir%' order by yr desc, winner ASC

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 asc,winner asc




[Escape character - a single quote: You can not put a single quotation mark directly on the string. However, using two consecutive single quotes may be treated as a single quotation mark in the string. ]
Such as 12 questions, some special foreign names, with a single quote character. EUGENE O'NEILL, you need to use this method.

Published 38 original articles · won praise 5 · Views 6011

Guess you like

Origin blog.csdn.net/luluisntlulu/article/details/100658251