mysql---SQLZOO:從WORLD選擇教程/ zh

來源:互聯網
上載者:User

標籤:image   section   mysq   lan   begin   sub   表格   country   else   

名稱 大陸 人口 gdp
阿富汗 亞洲 652230 25500100 20343000000
阿爾巴尼亞 歐洲 28748 2831741 12960000000
阿爾及利亞 非洲 2381741 37100000 188681000000
安道爾 歐洲 468 78115 3712000000
安哥拉 非洲 1246700 20609294 100990000000
...

名稱:國家名稱
大陸:洲份
面積:面積
人口:人口
gdp:國內生產總值

國家概況

在這教程中,我們會使用SELECT語句,對World表格進行查詢。

 

Show the name and the continent - but substitute Eurasia for Europe and Asia; substitute America - for each country in North America or South America or Caribbean. Show countries beginning with A or B

顯示名稱和大陸 - 但以歐亞和歐洲替代歐洲和亞洲; 替代美國 - 北美 或南美洲加勒比地區的每個國家。顯示以A或B開頭的國家

SELECT name,CASE WHEN continent IN(‘Europe‘,‘Asia‘)     THEN ‘Eurasia‘     WHEN continent IN(‘North America‘,‘South America‘,‘Caribbean‘)     THEN ‘America‘     ELSE continent ENDFROM worldWHERE name LIKE ‘A%‘ OR name LIKE ‘B%‘;

Put the continents right...

  • Oceania becomes Australasia
  • Countries in Eurasia and Turkey go to Europe/Asia
  • Caribbean islands starting with ‘B‘ go to North America, other Caribbean islands go to South America
Show the name, the original continent and the new continent of all countries.

把大陸放在正確的位置...

  • 大洋洲成為大洋洲
  • 歐亞和土耳其的國家去歐洲/亞洲
  • 以‘B‘ 開頭的加勒比群島去北美,其他加勒比群島去南美洲
顯示所有國家的名稱,原始大陸和新大陸。 
SELECT name,continent,CASE WHEN continent IN (‘Eurasia‘, ‘Turkey‘)     THEN ‘Europe/Asia‘     WHEN continent = ‘Oceania‘      THEN ‘Australasia‘     WHEN continent = ‘Caribbean‘          THEN          CASE           WHEN name LIKE ‘B%‘           THEN ‘North America‘          ELSE ‘South America‘          END     ELSE continent      ENDFROM worldORDER BY name ASC;

 

 

mysql---SQLZOO:從WORLD選擇教程/ zh

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.