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