SQL題集解答-3

鏈接直達(dá)

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

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

2.Show who won the 1962 prize for Literature.

SELECT winner
FROM nobel
WHERE yr = 1960
  AND subject = 'Physics'

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

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

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

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

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

6.Show all details of the presidential winners:

  • Theodore Roosevelt
  • Woodrow Wilson
  • Jimmy Carter
SELECT *
FROM nobel
WHERE winner IN ('Theodore Roosevelt',
                 'Woodrow Wilson',
                 'Jimmy Carter')

7.Show the winners with first name John

SELECT winner
FROM nobel
WHERE winner LIKE 'John%'

8.Show the 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')

9.Show the winners for 1980 excluding the Chemistry and Medicine

SELECT yr,
       subject,
       winner
FROM nobel
WHERE yr=1980
  AND subject NOT IN ('Chemistry',
                      'Medicine')

10.Show 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')

11.Find all details of the prize won by PETER GRüNBERG

SELECT *
FROM nobel
WHERE winner LIKE 'PETER GR%NBERG'

12.Find all details of the prize won by EUGENE O'NEILL

 select *
from nobel where winner like 'EUGENE O''NEILL'

13.Knights in order
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.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
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子同诫,更是在濱河造成了極大的恐慌盖矫,老刑警劉巖历涝,帶你破解...
    沈念sama閱讀 221,820評(píng)論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件兰迫,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡秧廉,警方通過(guò)查閱死者的電腦和手機(jī)伞广,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,648評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門拣帽,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人嚼锄,你說(shuō)我怎么就攤上這事诞外。” “怎么了灾票?”我有些...
    開封第一講書人閱讀 168,324評(píng)論 0 360
  • 文/不壞的土叔 我叫張陵峡谊,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我刊苍,道長(zhǎng)既们,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,714評(píng)論 1 297
  • 正文 為了忘掉前任正什,我火速辦了婚禮啥纸,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘婴氮。我一直安慰自己斯棒,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,724評(píng)論 6 397
  • 文/花漫 我一把揭開白布主经。 她就那樣靜靜地躺著荣暮,像睡著了一般。 火紅的嫁衣襯著肌膚如雪罩驻。 梳的紋絲不亂的頭發(fā)上穗酥,一...
    開封第一講書人閱讀 52,328評(píng)論 1 310
  • 那天,我揣著相機(jī)與錄音惠遏,去河邊找鬼砾跃。 笑死,一個(gè)胖子當(dāng)著我的面吹牛节吮,可吹牛的內(nèi)容都是我干的抽高。 我是一名探鬼主播,決...
    沈念sama閱讀 40,897評(píng)論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼透绩,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼翘骂!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起渺贤,我...
    開封第一講書人閱讀 39,804評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤雏胃,失蹤者是張志新(化名)和其女友劉穎请毛,沒(méi)想到半個(gè)月后志鞍,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,345評(píng)論 1 318
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡方仿,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,431評(píng)論 3 340
  • 正文 我和宋清朗相戀三年固棚,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了统翩。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,561評(píng)論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡此洲,死狀恐怖厂汗,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情呜师,我是刑警寧澤娶桦,帶...
    沈念sama閱讀 36,238評(píng)論 5 350
  • 正文 年R本政府宣布,位于F島的核電站汁汗,受9級(jí)特大地震影響衷畦,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜知牌,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,928評(píng)論 3 334
  • 文/蒙蒙 一祈争、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧角寸,春花似錦菩混、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,417評(píng)論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至亿柑,卻和暖如春帖烘,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背橄杨。 一陣腳步聲響...
    開封第一講書人閱讀 33,528評(píng)論 1 272
  • 我被黑心中介騙來(lái)泰國(guó)打工秘症, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人式矫。 一個(gè)月前我還...
    沈念sama閱讀 48,983評(píng)論 3 376
  • 正文 我出身青樓乡摹,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親采转。 傳聞我的和親對(duì)象是個(gè)殘疾皇子聪廉,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,573評(píng)論 2 359

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