Сортування за кількома стовпцями
Ми також можемо сортувати за декількома колонками. Нам потрібно вказати назви колонок розділені комами. Давайте розглянемо приклад, який отримує три колонки і сортує результати за двома з них: спочатку за population
, а потім за capital
.
SELECT ID, population, capital FROM country ORDER BY population, capital;
Here is the country
table we are working with:
Завдання
Swipe to start coding
Write an SQL query to retrieve four columns using the SELECT
statement, namely: continent
, region
, population
, and capital
(please retrieve these columns in this order). Then, sort the result by two of them: first by continent
, then by population
.
Рішення
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 2. Розділ 3