Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Sorting by Multiple Columns | Section
Practice
Projects
Quizzes & Challenges
Quizze
Challenges
/
SQL Fundamentals
Abschnitt 1. Kapitel 12
single

single

bookSorting by Multiple Columns

Swipe um das Menü anzuzeigen

We can also sort by multiple columns. We need to specify the column names separated by commas.

The first column specified in the sorting will have priority, and then the sorting will proceed according to the second column.

The syntax will look like this:

SELECT columns 
FROM table 
ORDER BY column_with_priority, column2, ...

Let’s look at the example that retrieves three columns and sorts the results by two of them: first by population and then by capital:

123
SELECT ID, population, capital FROM country ORDER BY population, capital;
copy
Aufgabe

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.

Lösung

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 12
single

single

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

some-alt