Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Checking for a Range of Values | Filtering Data
course content

Contenido del Curso

Introduction to SQL

Checking for a Range of ValuesChecking 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:

Tarea

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:

idnamecontinentregionsurfaceareacapitalpopulation
1JapanAsiaEastern Asia377829Tokyo126714000
2LatviaEuropeNULL64589Riga2424200
3MexicoNorth AmericaCentral America1958201Mexico City98881000
.....................
15MaltaEuropeSouthern Europe316Valletta380200

¿Todo estuvo claro?

Sección 3. Capítulo 5
toggle bottom row
course content

Contenido del Curso

Introduction to SQL

Checking for a Range of ValuesChecking 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:

Tarea

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:

idnamecontinentregionsurfaceareacapitalpopulation
1JapanAsiaEastern Asia377829Tokyo126714000
2LatviaEuropeNULL64589Riga2424200
3MexicoNorth AmericaCentral America1958201Mexico City98881000
.....................
15MaltaEuropeSouthern Europe316Valletta380200

¿Todo estuvo claro?

Sección 3. Capítulo 5
toggle bottom row
some-alt