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

book
Challenge: Sort the Countries by Region and Capital

Here is the country table we are working with:

Task

Swipe to start coding

Write an SQL query to 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.

Solution

SELECT name, region,capital
FROM country
ORDER BY region DESC, capital DESC;

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 6

toggle bottom row
Query ResultQuery Result
No query executed yet...
some-alt