Difference between revisions of "SELECT"
From SQLZOO
(→Exercises) |
|||
| Line 54: | Line 54: | ||
<source lang='sql' class='ans'> | <source lang='sql' class='ans'> | ||
SELECT name, region, population FROM bbc | SELECT name, region, population FROM bbc | ||
| + | </source> | ||
| + | </div> | ||
| + | |||
| + | |||
| + | <div class='qu'> | ||
| + | Show the name for the countries that have a population of at least 200 million. (200 million is 200000000, there are eight zeros) | ||
| + | <source lang='sql' class='def'> | ||
| + | SELECT name FROM bbc | ||
| + | WHERE population>250000000 | ||
| + | </source> | ||
| + | |||
| + | <source lang='sql' class='ans'> | ||
| + | SELECT name FROM bbc | ||
| + | WHERE population>200000000 | ||
</source> | </source> | ||
</div> | </div> | ||
Revision as of 07:18, 17 May 2012
BBC Country Profiles
This tutorial introduces SQL as a query language. We will be using the SELECT command on the table bbc:
| name | region | area | population | gdp |
|---|---|---|---|---|
| Afghanistan | South Asia | 652225 | 26000000 | |
| Albania | Europe | 28728 | 3200000 | 6656000000 |
| Algeria | Middle East | 2400000 | 32900000 | 75012000000 |
| Andorra | Europe | 468 | 64000 | |
| ... | ||||
Exercises
Using the SELECT statement.
Read the notes about this table. Issue the command:
SELECT name, region, population FROM bbc
Look at the output.
SELECT name, region, population FROM bbc
SELECT name, region, population FROM bbc
Show the name for the countries that have a population of at least 200 million. (200 million is 200000000, there are eight zeros)
SELECT name FROM bbc WHERE population>250000000
SELECT name FROM bbc WHERE population>200000000