MySQL---Sqlzoo: from World Selection Tutorial/ZH

Source: Internet
Author: User

name Mainland Area population GDP
Afghanistan Asia 652230 25500100 20343000000
Albania Europe 28748 2831741 12960000000
Algeria Africa 2381741 37100000 188681000000
Andorra Europe 468 78115 3712000000
Angola Africa 1246700 20609294 100990000000
...

Name: Country name
Continents: Continents
Size: Area
Population: Population
GDP: Gross domestic product

Country Profile

In this tutorial, we use the SELECT statement to query the World table.

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

display names and continents-but with Europe and Asia and Europe as a substitute for Europe and Asia; Alternative to us - North or South America or the Caribbean Region of each country. Show countries that start with a or B

SELECTname, Case  whenContinentinch('Europe','Asia')      Then 'Eurasia'      whenContinentinch('North America','South America','Caribbean')      Then 'America'     ELSEContinentEND from WorldWHEREName like 'A%' ORName 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, and other Caribbean islands go-South America
Show the name, the original continent and the new continent of all countries.

Put the continent in the right place ...

    • Oceania becomes Oceania
    • Countries of Eurasia and Turkey go to Europe/Asia
    • Caribbean islands beginning with ' B ' to North America , other Caribbean islands to South America
show the names of all countries, the original continent and the new continent.
SELECTName,continent, Case  whenContinentinch('Eurasia','Turkey')      Then 'Europe/asia'      whenContinent= 'Oceania'       Then 'Australasia'      whenContinent= 'Caribbean'           Then           Case            whenName like 'B%'            Then 'North America'          ELSE 'South America'          END     ELSEContinentEND from WorldORDER  byNameASC;

MySQL---Sqlzoo: from World Selection Tutorial/ZH

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.