SQL練習_2 | 3 | SQLZOO_20191008

本系列刷題筆記主要用以記錄刷SQLZOO的過程中的思路已亥、個人答案以及陌生的或者新的知識點誉券。

題目來源 - SQLZOO
SQLZOO中題目中文版本與英文版本略有差異桂塞,題目以英文版為準

相關(guān)文章
SQL練習_1 | SQLZOO_20191002

3 Select from Nobel

查詢表格

查詢表格_Nobel

3_1 Change the query shown so that it displays Nobel prizes for 1950.

SELECT yr,
       subject,
       winner
FROM nobel
WHERE yr = 1950

3_2 Show who won the 1962 prize for Literature.

SELECT winner
FROM nobel
WHERE yr = 1962
AND   subject = 'Literature'

3_3 Show the year and subject that won 'Albert Einstein' his prize.

SELECT yr,
       subject
FROM nobel
WHERE winner = 'Albert Einstein'

3_4 Give the name of the 'Peace' winners since the year 2000, including 2000.

SELECT winner
FROM nobel
WHERE subject = 'Peace'
AND   yr >= '2000'

3_5 Show all details (yr, subject, winner) of the Literature prize winners for 1980 to 1989 inclusive.

SELECT *
FROM nobel
WHERE subject = 'Literature'
AND   yr BETWEEN '1980' AND '1989'

3_6 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')

3_7 Show the winners with first name John.

SELECT winner
FROM nobel
WHERE winner like ('John%')

3_8 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    (yr = '1984' AND subject = 'Chemistry')

3_9 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 NOT IN ('Chemistry','Medicine')

3_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 (yr < '1910' AND subject = 'Medicine')
OR    (yr >= '2004' AND subject = 'Literature')

3_11 Find all details of the prize won by PETER GRüNBERG

SELECT *
FROM nobel
WHERE winner = 'PETER GRüNBERG'

3_12 Find all details of the prize won by EUGENE O'NEILL

SELECT *
FROM nobel
WHERE winner = 'EUGENE O''NEILL'

3_13 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%'
ORDER BY yr DESC,
         winner ASC

3_14 Show the 1984 winners and subject ordered by subject and winner name; but list Chemistry and Physics last.

The expression subject IN ('Chemistry','Physics') can be used as a value - it will be 0 or 1.

SELECT winner,
       subject
FROM nobel
WHERE yr = 1984
ORDER BY subject IN ('Physics','Chemistry'),
         subject,
         winner
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市凉逛,隨后出現(xiàn)的幾起案子性宏,更是在濱河造成了極大的恐慌,老刑警劉巖状飞,帶你破解...
    沈念sama閱讀 206,839評論 6 482
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件毫胜,死亡現(xiàn)場離奇詭異,居然都是意外死亡诬辈,警方通過查閱死者的電腦和手機酵使,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,543評論 2 382
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來焙糟,“玉大人口渔,你說我怎么就攤上這事〈┐椋” “怎么了缺脉?”我有些...
    開封第一講書人閱讀 153,116評論 0 344
  • 文/不壞的土叔 我叫張陵,是天一觀的道長悦穿。 經(jīng)常有香客問我枪向,道長,這世上最難降的妖魔是什么咧党? 我笑而不...
    開封第一講書人閱讀 55,371評論 1 279
  • 正文 為了忘掉前任,我火速辦了婚禮陨亡,結(jié)果婚禮上傍衡,老公的妹妹穿的比我還像新娘。我一直安慰自己负蠕,他們只是感情好蛙埂,可當我...
    茶點故事閱讀 64,384評論 5 374
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著遮糖,像睡著了一般绣的。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,111評論 1 285
  • 那天屡江,我揣著相機與錄音芭概,去河邊找鬼。 笑死惩嘉,一個胖子當著我的面吹牛罢洲,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播文黎,決...
    沈念sama閱讀 38,416評論 3 400
  • 文/蒼蘭香墨 我猛地睜開眼惹苗,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了耸峭?” 一聲冷哼從身側(cè)響起桩蓉,我...
    開封第一講書人閱讀 37,053評論 0 259
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎劳闹,沒想到半個月后院究,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 43,558評論 1 300
  • 正文 獨居荒郊野嶺守林人離奇死亡玷或,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,007評論 2 325
  • 正文 我和宋清朗相戀三年儡首,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片偏友。...
    茶點故事閱讀 38,117評論 1 334
  • 序言:一個原本活蹦亂跳的男人離奇死亡蔬胯,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出位他,到底是詐尸還是另有隱情氛濒,我是刑警寧澤,帶...
    沈念sama閱讀 33,756評論 4 324
  • 正文 年R本政府宣布鹅髓,位于F島的核電站舞竿,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏窿冯。R本人自食惡果不足惜骗奖,卻給世界環(huán)境...
    茶點故事閱讀 39,324評論 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望醒串。 院中可真熱鬧执桌,春花似錦、人聲如沸芜赌。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,315評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽缠沈。三九已至膘壶,卻和暖如春错蝴,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背颓芭。 一陣腳步聲響...
    開封第一講書人閱讀 31,539評論 1 262
  • 我被黑心中介騙來泰國打工顷锰, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人畜伐。 一個月前我還...
    沈念sama閱讀 45,578評論 2 355
  • 正文 我出身青樓馍惹,卻偏偏與公主長得像,于是被迫代替她去往敵國和親玛界。 傳聞我的和親對象是個殘疾皇子万矾,可洞房花燭夜當晚...
    茶點故事閱讀 42,877評論 2 345

推薦閱讀更多精彩內(nèi)容