Sqlzoo exercise answer -- SELECTbasics/zh

Source: Internet
Author: User

Sqlzoo exercise answer -- SELECTbasics/zh

This tutorial introduces 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.