Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge: Sort the Countries by Region and Capital | Sorting Retrieved Data
Introduction to SQL
course content

Course Content

Introduction to SQL

Introduction to SQL

1. Retrieving Data
2. Sorting Retrieved Data
3. Filtering Data
4. Advanced Data Filtering
5. Aggregate Functions

Challenge: Sort the Countries by Region and Capital

Task

Retrieve three columns from the country table using the SELECT statement, namely: name, region, and capital (please retrieve these columns in this order). Sort the result by two of them - first by region in descending order, then by capital, also in descending order.

Here's a short example of the country table:

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

Task

Retrieve three columns from the country table using the SELECT statement, namely: name, region, and capital (please retrieve these columns in this order). Sort the result by two of them - first by region in descending order, then by capital, also in descending order.

Here's a short example of the country table:

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

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 2. Chapter 6
toggle bottom row

Challenge: Sort the Countries by Region and Capital

Task

Retrieve three columns from the country table using the SELECT statement, namely: name, region, and capital (please retrieve these columns in this order). Sort the result by two of them - first by region in descending order, then by capital, also in descending order.

Here's a short example of the country table:

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

Task

Retrieve three columns from the country table using the SELECT statement, namely: name, region, and capital (please retrieve these columns in this order). Sort the result by two of them - first by region in descending order, then by capital, also in descending order.

Here's a short example of the country table:

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

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 2. Chapter 6
toggle bottom row

Challenge: Sort the Countries by Region and Capital

Task

Retrieve three columns from the country table using the SELECT statement, namely: name, region, and capital (please retrieve these columns in this order). Sort the result by two of them - first by region in descending order, then by capital, also in descending order.

Here's a short example of the country table:

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

Task

Retrieve three columns from the country table using the SELECT statement, namely: name, region, and capital (please retrieve these columns in this order). Sort the result by two of them - first by region in descending order, then by capital, also in descending order.

Here's a short example of the country table:

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

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Task

Retrieve three columns from the country table using the SELECT statement, namely: name, region, and capital (please retrieve these columns in this order). Sort the result by two of them - first by region in descending order, then by capital, also in descending order.

Here's a short example of the country table:

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

Switch to desktop for real-world practiceContinue from where you are using one of the options below
Section 2. Chapter 6
Switch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt