This tutorial introduces SQL statement. We will use the SELECT statement. We will use the WORLD table example tutorial to introduce SQL statement. We will use the SELECT statement. We will use the WORLD Table
| Name |
Continent |
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
Continent: continent
Area: area labels
Population: population
Gdp: total domestic production value
1. this example shows the population of 'France France. The string should be in 'simple quota.
Modify this example to show the population of Germany and Germany.
SELECT population FROM world WHERE name = 'Germany'
2. check the population density (population/area) of a country with a surface area of more than 5,000,000 square kilometers ). Population density is not a dimension in the WORLD table, but we can use a formula (population/area) to calculate it. Modify this example to check the number of countries with over 5,000,000 square kilometers, for each country, her name and total gdp per capita (gdp/population) are shown ).
SELECT name, gdp/population FROM world WHERE area > 5000000
3. query list: the word "IN" allows us to check whether a category is IN the list.
This example shows the country name and population of "Luxembourg", "Mauritius" and "Samoa Morya.
Shows the country name and population of "Ireland ", "Iceland Ice", and "Denmark Dan.
SELECT name, population FROM world WHERE name IN ('Ireland', 'Iceland', 'Denmark');
4. which countries are too small or not?
BETWEEN allows too many queries-note that this is inclusive. This example shows the country name and country name of 250,000 and 300,000 respectively.
Modify this example to show the country name and the country name between 200,000 and 250,000.
SELECT name, area FROM world WHERE area BETWEEN 200000 AND 250000