Course Content
Introduction to SQL
Introduction to SQL
Checking for a Range of Values
To check for a range of values, we should use the BETWEEN
operator. This operator requires two values: the start-value and the end-value of the range. Also, the AND
keyword should be placed between these values.
Let's see an example:
SELECT name, population FROM country WHERE population BETWEEN 100000 AND 3000000;
Task
Write an SQL query that returns the name
, capital
, and population
columns from the country
table (please retrieve these columns in this order), for all countries with a population
between 6000000 and 80000000. Then sort the result by capital
from A to Z.
You have to do it like in the example above.
Pay attention to the population
, and enter these numbers correctly. Otherwise, you will get an Internal server error
.
Here's a short example of the country
table:
id | name | continent | region | surfacearea | capital | population |
1 | Japan | Asia | Eastern Asia | 377829 | Tokyo | 126714000 |
2 | Latvia | Europe | NULL | 64589 | Riga | 2424200 |
3 | Mexico | North America | Central America | 1958201 | Mexico City | 98881000 |
... | ... | ... | ... | ... | ... | ... |
15 | Malta | Europe | Southern Europe | 316 | Valletta | 380200 |
Task
Write an SQL query that returns the name
, capital
, and population
columns from the country
table (please retrieve these columns in this order), for all countries with a population
between 6000000 and 80000000. Then sort the result by capital
from A to Z.
You have to do it like in the example above.
Pay attention to the population
, and enter these numbers correctly. Otherwise, you will get an Internal server error
.
Here's a short example of the country
table:
id | name | continent | region | surfacearea | capital | population |
1 | Japan | Asia | Eastern Asia | 377829 | Tokyo | 126714000 |
2 | Latvia | Europe | NULL | 64589 | Riga | 2424200 |
3 | Mexico | North America | Central America | 1958201 | Mexico City | 98881000 |
... | ... | ... | ... | ... | ... | ... |
15 | Malta | Europe | Southern Europe | 316 | Valletta | 380200 |
Everything was clear?
Checking for a Range of Values
To check for a range of values, we should use the BETWEEN
operator. This operator requires two values: the start-value and the end-value of the range. Also, the AND
keyword should be placed between these values.
Let's see an example:
SELECT name, population FROM country WHERE population BETWEEN 100000 AND 3000000;
Task
Write an SQL query that returns the name
, capital
, and population
columns from the country
table (please retrieve these columns in this order), for all countries with a population
between 6000000 and 80000000. Then sort the result by capital
from A to Z.
You have to do it like in the example above.
Pay attention to the population
, and enter these numbers correctly. Otherwise, you will get an Internal server error
.
Here's a short example of the country
table:
id | name | continent | region | surfacearea | capital | population |
1 | Japan | Asia | Eastern Asia | 377829 | Tokyo | 126714000 |
2 | Latvia | Europe | NULL | 64589 | Riga | 2424200 |
3 | Mexico | North America | Central America | 1958201 | Mexico City | 98881000 |
... | ... | ... | ... | ... | ... | ... |
15 | Malta | Europe | Southern Europe | 316 | Valletta | 380200 |
Task
Write an SQL query that returns the name
, capital
, and population
columns from the country
table (please retrieve these columns in this order), for all countries with a population
between 6000000 and 80000000. Then sort the result by capital
from A to Z.
You have to do it like in the example above.
Pay attention to the population
, and enter these numbers correctly. Otherwise, you will get an Internal server error
.
Here's a short example of the country
table:
id | name | continent | region | surfacearea | capital | population |
1 | Japan | Asia | Eastern Asia | 377829 | Tokyo | 126714000 |
2 | Latvia | Europe | NULL | 64589 | Riga | 2424200 |
3 | Mexico | North America | Central America | 1958201 | Mexico City | 98881000 |
... | ... | ... | ... | ... | ... | ... |
15 | Malta | Europe | Southern Europe | 316 | Valletta | 380200 |
Everything was clear?
Checking for a Range of Values
To check for a range of values, we should use the BETWEEN
operator. This operator requires two values: the start-value and the end-value of the range. Also, the AND
keyword should be placed between these values.
Let's see an example:
SELECT name, population FROM country WHERE population BETWEEN 100000 AND 3000000;
Task
Write an SQL query that returns the name
, capital
, and population
columns from the country
table (please retrieve these columns in this order), for all countries with a population
between 6000000 and 80000000. Then sort the result by capital
from A to Z.
You have to do it like in the example above.
Pay attention to the population
, and enter these numbers correctly. Otherwise, you will get an Internal server error
.
Here's a short example of the country
table:
id | name | continent | region | surfacearea | capital | population |
1 | Japan | Asia | Eastern Asia | 377829 | Tokyo | 126714000 |
2 | Latvia | Europe | NULL | 64589 | Riga | 2424200 |
3 | Mexico | North America | Central America | 1958201 | Mexico City | 98881000 |
... | ... | ... | ... | ... | ... | ... |
15 | Malta | Europe | Southern Europe | 316 | Valletta | 380200 |
Task
Write an SQL query that returns the name
, capital
, and population
columns from the country
table (please retrieve these columns in this order), for all countries with a population
between 6000000 and 80000000. Then sort the result by capital
from A to Z.
You have to do it like in the example above.
Pay attention to the population
, and enter these numbers correctly. Otherwise, you will get an Internal server error
.
Here's a short example of the country
table:
id | name | continent | region | surfacearea | capital | population |
1 | Japan | Asia | Eastern Asia | 377829 | Tokyo | 126714000 |
2 | Latvia | Europe | NULL | 64589 | Riga | 2424200 |
3 | Mexico | North America | Central America | 1958201 | Mexico City | 98881000 |
... | ... | ... | ... | ... | ... | ... |
15 | Malta | Europe | Southern Europe | 316 | Valletta | 380200 |
Everything was clear?
To check for a range of values, we should use the BETWEEN
operator. This operator requires two values: the start-value and the end-value of the range. Also, the AND
keyword should be placed between these values.
Let's see an example:
SELECT name, population FROM country WHERE population BETWEEN 100000 AND 3000000;
Task
Write an SQL query that returns the name
, capital
, and population
columns from the country
table (please retrieve these columns in this order), for all countries with a population
between 6000000 and 80000000. Then sort the result by capital
from A to Z.
You have to do it like in the example above.
Pay attention to the population
, and enter these numbers correctly. Otherwise, you will get an Internal server error
.
Here's a short example of the country
table:
id | name | continent | region | surfacearea | capital | population |
1 | Japan | Asia | Eastern Asia | 377829 | Tokyo | 126714000 |
2 | Latvia | Europe | NULL | 64589 | Riga | 2424200 |
3 | Mexico | North America | Central America | 1958201 | Mexico City | 98881000 |
... | ... | ... | ... | ... | ... | ... |
15 | Malta | Europe | Southern Europe | 316 | Valletta | 380200 |