ホームページ > データベース > mysql チュートリアル > sqlzoo练习答案--SELECTfromNobelTutorial/zh_MySQL

sqlzoo练习答案--SELECTfromNobelTutorial/zh_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
リリース: 2016-05-27 13:45:32
オリジナル
2651 人が閲覧しました

nobel 諾貝爾獎得獎者

我們繼續練習簡單的單一表格SQL查詢。

這個教程是有關諾貝爾獎得獎者的:

nobel(yr, subject, winner)
ログイン後にコピー
yr subject winner
1960 Chemistry Willard F. Libby
1960 Literature Saint-John Perse
1960 Medicine Sir Frank Macfarlane Burnet
1960 Medicine Peter Madawar
...

yr: 年份
subject: 獎項
winner: 得獎者

1、更改查詢以顯示1950年諾貝爾獎的獎項資料。

SELECT yr, subject, winner
  FROM nobel
 WHERE yr = 1950
ログイン後にコピー
2、顯示誰贏得了1962年文學獎(Literature)。
SELECT winner
  FROM nobel
 WHERE yr = 1962
   AND subject = 'Literature'
ログイン後にコピー

3、顯示“愛因斯坦”('Albert Einstein') 的獲獎年份和獎項。
select yr,subject from nobel where winner = 'Albert Einstein'
ログイン後にコピー
4、顯示2000年及以後的和平獎(‘Peace’)得獎者。
select winner from nobel where yr>=2000 and subject='Peace'
ログイン後にコピー
5、顯示1980年至1989年(包含首尾)的文學獎(Literature)獲獎者所有細節(年,主題,獲獎者)。
select * from nobel where yr between 1980 and 1989 and subject = 'Literature'
ログイン後にコピー
6、

顯示總統獲勝者的所有細節:

  • 西奧多?羅斯福 Theodore Roosevelt
  • 伍德羅?威爾遜 Woodrow Wilson
  • 吉米?卡特 Jimmy Carter
    SELECT * FROM nobel
     WHERE winner IN ('Theodore Roosevelt',
                      'Woodrow Wilson',
                      'Jimmy Carter')
    ログイン後にコピー

    7、顯示名字為John 的得獎者。 (注意:外國人名字(First name)在前,姓氏(Last name)在後)

    select winner from nobel where winner like 'John%'
    ログイン後にコピー

    8、顯示1980年物理學(physics)獲獎者,及1984年化學獎(chemistry)獲得者
    select * from nobel where (yr=1980 and subject='physics') or (yr=1984 and subject='chemistry')
    ログイン後にコピー

    9、查看1980年獲獎者,但不包括化學獎(Chemistry)和醫學獎(Medicine)。
    select * from nobel where subject not in('Chemistry','Medicine') and yr=1980
    ログイン後にコピー

    10、顯示早期的醫學獎(Medicine)得獎者(1910之前,不包括1910),及近年文學獎(Literature)得獎者(2004年以後,包括2004年)。
    select * from nobel where (yr<1910 and subject=&#39;Medicine&#39;) or (yr>=2004 and subject=&#39;Literature&#39;)
    ログイン後にコピー
    11、Find all details of the prize won by PETER GRüNBERG
    select * from nobel where winner = &#39;Peter Gr&uuml;nberg&#39;
    ログイン後にコピー

    12、查找尤金?奧尼爾EUGENE O'NEILL得獎的所有細節 Find all details of the prize won by EUGENE O'NEILL
    select * from nobel where winner = &#39;Eugene O\&#39;Neill&#39;
    ログイン後にコピー
    13、

    騎士列隊 Knights in order

    列出爵士的獲獎者、年份、獎頁(爵士的名字以Sir開始)。先顯示最新獲獎者,然後同年再按名稱順序排列。

    select winner,yr,subject from nobel where winner like &#39;Sir%&#39; 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 (&#39;Physics&#39;,&#39;Chemistry&#39;),subject asc,winner asc
    ログイン後にコピー
関連ラベル:
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のチュートリアル
詳細>
関連するチュートリアル
人気のおすすめ
最新のコース
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート