In this tutorial you will use the SELECT command on the table <code>world</code>:

In this tutorial you will use the SELECT command on the table <code>world</code>:

<div class='extra_space' style='width:1em; height:2.5em;'></div>

<div class='extra_space' style='width:1em; height:2.5em;'></div>

+

==Introduction==

<div class='qu'>

<div class='qu'>

[[Read_the_notes_about_this_table. |Read the notes about this table.]] Observe the result of running this SQL command to show the name, continent and population of all countries.

[[Read_the_notes_about_this_table. |Read the notes about this table.]] Observe the result of running this SQL command to show the name, continent and population of all countries.

Line 29:

Line 30:

SELECT name, continent, population FROM world

SELECT name, continent, population FROM world

</source>

</source>

−

</div>

</div>

+

==Large Countries==

<div class='qu'>

<div class='qu'>

[[WHERE_filters |How to use WHERE to filter records.]]

[[WHERE_filters |How to use WHERE to filter records.]]

Line 40:

Line 41:

WHERE population = 64105700

WHERE population = 64105700

</source>

</source>

−

<source lang='sql' class='ans'>

<source lang='sql' class='ans'>

SELECT name FROM world

SELECT name FROM world

Line 47:

Line 47:

</div>

</div>

−

+

==Per capita GDP==

<div class='qu'>

<div class='qu'>

Give the <code>name</code> and the '''per capita GDP''' for those countries with a <code>population</code> of at least 200 million.

Give the <code>name</code> and the '''per capita GDP''' for those countries with a <code>population</code> of at least 200 million.

Line 55:

Line 55:

<source lang='sql' class='def'>

<source lang='sql' class='def'>

</source>

</source>

−

<source lang='sql' class='ans'>

<source lang='sql' class='ans'>

SELECT name, gdp/population FROM world

SELECT name, gdp/population FROM world

WHERE population > 200000000

WHERE population > 200000000

</source>

</source>

+

{{#ev:youtube|5Md75Wfpocs}}

</div>

</div>

+

==South America In millions==

<div class='qu'>

<div class='qu'>

Show the <code>name</code> and <code>population</code> in millions for the countries of the <code>continent</code> 'South America'.

Show the <code>name</code> and <code>population</code> in millions for the countries of the <code>continent</code> 'South America'.

Line 67:

Line 68:

<source lang='sql' class='def'>

<source lang='sql' class='def'>

</source>

</source>

−

<source lang='sql' class='ans'>

<source lang='sql' class='ans'>

SELECT name, population/1000000 FROM world

SELECT name, population/1000000 FROM world

Line 74:

Line 74:

</div>

</div>

+

==France, Germany, Italy==

<div class='qu'>

<div class='qu'>

Show the <code>name</code> and <code>population</code> for France, Germany, Italy

Show the <code>name</code> and <code>population</code> for France, Germany, Italy

Line 85:

Line 86:

</div>

</div>

+

==United==

<div class='qu'>

<div class='qu'>

Show the countries which have a <code>name</code> that includes the word 'United'

Show the countries which have a <code>name</code> that includes the word 'United'

Line 97:

Line 99:

<div>

<div>

+

==Two ways to be big==

<div class='qu'>

<div class='qu'>

Two ways to be big: A country is '''big''' if it has an area of more than 3 million sq km or it has a population of more than 250 million.

Two ways to be big: A country is '''big''' if it has an area of more than 3 million sq km or it has a population of more than 250 million.

Line 112:

Line 115:

<div>

<div>

+

==One or the other (but not both)==

<div class='qu'>

<div class='qu'>

<p class=imper>Exclusive OR (XOR). Show the countries that are big by area or big by population but not both. Show name, population and area.</p>

<p class=imper>Exclusive OR (XOR). Show the countries that are big by area or big by population but not both. Show name, population and area.</p>

Line 129:

Line 133:

</div>

</div>

+

==Rounding==

<div class='qu'>

<div class='qu'>

Show the <code>name</code> and <code>population</code> in millions and the GDP in billions for the countries of the <code>continent</code> 'South America'. Use the [[ROUND]] function to show the values to two decimal places.

Show the <code>name</code> and <code>population</code> in millions and the GDP in billions for the countries of the <code>continent</code> 'South America'. Use the [[ROUND]] function to show the values to two decimal places.