|
|
(41 intermediate revisions by 13 users not shown) |
Line 1: |
Line 1: |
− | ==BBC Country Profiles==
| |
− | This tutorial introduces SQL as a query language. We will be using the SELECT command on the table bbc:
| |
− | <table style='' border='1'><tr>
| |
− | <th>name</th>
| |
− | <th>region</th>
| |
− | <th>area</th>
| |
− | <th>population</th>
| |
− | <th>gdp</th>
| |
− | </tr>
| |
− | <tr>
| |
− | <td>Afghanistan</td>
| |
− | <td>South Asia</td>
| |
− | <td align='right'>652225</td>
| |
− | <td align='right'>26000000</td>
| |
− | <td></td>
| |
− | </tr>
| |
− | <tr>
| |
− | <td>Albania</td>
| |
− | <td>Europe</td>
| |
− | <td align='right'>28728</td>
| |
− | <td align='right'>3200000</td>
| |
− | <td align='right'>6656000000</td>
| |
− | </tr>
| |
− | <tr>
| |
− | <td>Algeria</td>
| |
− | <td>Middle East</td>
| |
− | <td align='right'>2400000</td>
| |
− | <td align='right'>32900000</td>
| |
− | <td align='right'>75012000000</td>
| |
− | </tr>
| |
− | <tr>
| |
− | <td>Andorra</td>
| |
− | <td>Europe</td>
| |
− | <td align='right'>468</td>
| |
− | <td align='right'>64000</td>
| |
− | <td></td>
| |
− | </tr>
| |
− | <tr>
| |
− | <td colspan='5'>...</td>
| |
− | </tr>
| |
− | </table>
| |
− | ==Exercises==
| |
− | Using the <code>SELECT</code> statement.
| |
| | | |
− | <div class='qu'>
| |
− | [[Read the notes about this table.]]
| |
− | Issue the command:
| |
− | SELECT name, region, population FROM bbc
| |
− | Look at the output.
| |
− | <source lang='sql' class='def'>
| |
− | SELECT name, region, population FROM bbc
| |
− | </source>
| |
− |
| |
− | <source lang='sql' class='ans'>
| |
− | 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>
| |
− | </div>
| |