SELECT from Nobel Tutorial
阿新 • • 發佈:2020-07-28
02.SELECT from Nobel Tutorial
注意:where語句中對錶示條件的需要用單引號,下面的譯文使用的是有道翻譯如有不正確,請直接投訴有道
01.Change the query shown so that it displays Nobel prizes for 1950.
譯文:更改顯示的查詢,使其顯示1950年的諾貝爾獎。
SELECT yr, subject, winner FROM nobel WHERE yr = 1950
02.Show who won the 1962 prize for Literature.
譯文:展示誰獲得了1962年的文學獎。
SELECTwinner FROM nobel WHERE yr = 1962 AND subject = 'Literature'
03.Show the year and subject that won 'Albert Einstein' his prize.
譯文:展示“愛因斯坦”獲獎的年份和主題。
select yr, subject from nobel where winner ='Albert Einstein'
04.Give the name of the 'Peace' winners since the year 2000, including 2000.
譯文:請說出自2000年(包括2000年)以來的“和平”獲獎者的名字。
select winner from nobel where yr >= 2000 and subject='Peace'
05.Show all details (yr,subject,winner) of the Literature prize winners for 1980 to 1989 inclusive.
譯文:展示1980年至1989年包括在內的所有文學獎得主的詳細資料(年份、主題、獲獎作品)
select * from nobel where (yr between 1980 and 1989) and subject = 'Literature'
06.
Show all details of the presidential winners:
-
Theodore Roosevelt
-
Woodrow Wilson
-
Jimmy Carter
-
Barack Obama
譯文:顯示總統候選人的所有資訊:
西奧多。羅斯福
伍德羅·威爾遜
吉米•卡特
巴拉克•奧巴馬(Barack Obama)
SELECT * FROM nobel WHERE winner IN ('Theodore Roosevelt', 'Woodrow Wilson', 'Jimmy Carter', 'Barack Obama')
07.Show the winners with first name John
譯文:顯示姓名的第一個字為約翰的獲獎者
select winner from nobel where winner like 'John%'
08.Show the year, subject, and name of Physics winners for 1980 together with the Chemistry winners for 1984.
譯文:展示1980年物理獲獎者和1984年化學獲獎者的年份、科目和名字。
select * from nobel where (yr=1980 and subject='Physics') or (yr=1984 and subject='Chemistry')
09.Show the year, subject, and name of winners for 1980 excluding Chemistry and Medicine
譯文:請列出1980年的獲獎年份、獲獎科目和獲獎名單,化學和醫學除外
select * from nobel where yr=1980 and subject not in ('Chemistry','Medicine')
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)
譯文:展示(1910年以前,不包括1910年)獲得“醫學獎”的人的資訊,以及後來(2004年以後,包括2004年)獲得“文學獎”的人的資訊
select * 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 all details of the prize won by EUGENE O'NEILL
譯文:找到尤金·奧尼爾獲獎的所有資訊
# 查詢的名字裡面有個單引號需要使用兩個單引號 即’EUGENE O’’NEILL’
select * from nobel where winner ='EUGENE O''NEILL'
13.List the winners, year and subject where the winner starts withSir. Show the the most recent first, then by name order.
譯文:列出獲獎者的名字,年份和主題,獲獎者以“先生”開頭。先顯示最近的,然後按名字順序排列。
select winner,yr,subject from nobel where winner like 'Sir%' order by yr desc, winner asc
14.Show the 1984 winners and subject ordered by subject and winner name; but list Chemistry and Physics last.
譯文:顯示1984年獲獎者和科目排序的科目和獲獎者的名字;但是把化學和物理列在最後。
SELECT winner, subject FROM nobel WHERE yr=1984 ORDER BY subject in('Physics','Chemistry') ,subject,winner
練習網址:https://sqlzoo.net/wiki/SELECT_from_Nobel_Tutorial
——————————————————————————————————————————————————————————————————————————————————————————————————————————