User:Marek
From SQLZOO
Contents |
[edit] Temp reference
[edit] Counter with Local Storage
You have visited the page x
times.
Reset the counter
Summary
[edit] Test qu2 tutorial questions
Completion information
The example shows the population of 'France'. Strings should be in 'single quotes';
Show the population of Germany
SELECT population FROM bbc WHERE name = 'France'
SELECT population FROM bbc WHERE name = 'Germany'
Completion information
This query shows the population density
population/area
for each country where the area is over 5,000,000 km2.Show the per capita gdp:
gdp/population
for each country where the area is over 5,000,000 km2SELECT name, population/area FROM bbc WHERE area > 5000000
SELECT name, gdp/population FROM bbc WHERE area > 5000000
Completion information
Where to find some very small, very rich countries.
We use AND to ensure that two or more conditions hold
true.
The example shows the countries where the population is small and the
gdp is high.
Show the name and region where the area is less then 2000 and the gdp is more than 5000000000
SELECT name , region FROM bbc WHERE population < 2000000 AND gdp > 5000000000
SELECT name , region FROM bbc WHERE area < 2000 AND gdp > 5000000000
Completion information
Checking a list The word IN allows us to check if an item is in a list. The example shows the name and population for the countries 'Ireland', 'Iceland' and 'Denmark'
Show the name and the population for 'Denmark', 'Finland', 'Norway', 'Sweden'
SELECT name, population FROM bbc WHERE name IN ('Ireland', 'Iceland', 'Denmark')
SELECT name, population FROM bbc WHERE name IN ('Denmark', 'Finland', 'Norway', 'Sweden')
Completion information
What are the countries beginning with G?
The word LIKE permits pattern matching - % is the wildcard.
The examples shows countries beginning with D
Show each country that begins with G
SELECT name FROM bbc WHERE name LIKE 'D%'
SELECT name FROM bbc WHERE name LIKE 'G%'