nobel 諾貝爾獎得獎者我們繼續練習簡單的單一表格sql查詢。
這個教程是有關諾貝爾獎得獎者的:
nobel(yr, subject, winner)
yrsubjectwinner
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 carterselect * 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=2004 and subject='literature')
11、find all details of the prize won by peter grünbergselect * from nobel where winner = 'peter grünberg'
12、查找尤金?奧尼爾eugene o'neill得獎的所有細節 find all details of the prize won by eugene o'neillselect * from nobel where winner = 'eugene o\'neill'
13、騎士列隊 knights in order
列出爵士的獲獎者、年份、獎頁(爵士的名字以sir開始)。先顯示最新獲獎者,然後同年再按名稱順序排列。
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