Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Sorting in DESCending order | Sorting
SQL Basics
course content

Зміст курсу

SQL Basics

SQL Basics

1. Selecting
2. Filtering
3. Aggregating
4. Sorting
5. Grouping
6. Practicing

bookSorting in DESCending order

But what if we want to get the highest observation? As you remember, sorting in SQL is realized in ascending order, so the biggest values are on the bottom.

In SQL you can easily sort in reverse (descending) order. To do it use DESC keyword followed or preceded by column name. You can also put column names within the parenthesis of DESC keyword. So, there are two variants of using DESC:

  • DESC(col_name);
  • col_name DESC;

For example, we can order cars by mileage, but this time in descending order.

123
SELECT * FROM audi_cars ORDER BY mileage DESC
copy

Please note, that there is also ASC keyword in SQL used for ascending sorting. Since default sorting in SQL is in ascending order, this keyword is rarely used.

Завдання

From the audi_cars table extract all the cars sorted by column tax in descending order.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 4. Розділ 2
toggle bottom row

bookSorting in DESCending order

But what if we want to get the highest observation? As you remember, sorting in SQL is realized in ascending order, so the biggest values are on the bottom.

In SQL you can easily sort in reverse (descending) order. To do it use DESC keyword followed or preceded by column name. You can also put column names within the parenthesis of DESC keyword. So, there are two variants of using DESC:

  • DESC(col_name);
  • col_name DESC;

For example, we can order cars by mileage, but this time in descending order.

123
SELECT * FROM audi_cars ORDER BY mileage DESC
copy

Please note, that there is also ASC keyword in SQL used for ascending sorting. Since default sorting in SQL is in ascending order, this keyword is rarely used.

Завдання

From the audi_cars table extract all the cars sorted by column tax in descending order.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 4. Розділ 2
toggle bottom row

bookSorting in DESCending order

But what if we want to get the highest observation? As you remember, sorting in SQL is realized in ascending order, so the biggest values are on the bottom.

In SQL you can easily sort in reverse (descending) order. To do it use DESC keyword followed or preceded by column name. You can also put column names within the parenthesis of DESC keyword. So, there are two variants of using DESC:

  • DESC(col_name);
  • col_name DESC;

For example, we can order cars by mileage, but this time in descending order.

123
SELECT * FROM audi_cars ORDER BY mileage DESC
copy

Please note, that there is also ASC keyword in SQL used for ascending sorting. Since default sorting in SQL is in ascending order, this keyword is rarely used.

Завдання

From the audi_cars table extract all the cars sorted by column tax in descending order.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

But what if we want to get the highest observation? As you remember, sorting in SQL is realized in ascending order, so the biggest values are on the bottom.

In SQL you can easily sort in reverse (descending) order. To do it use DESC keyword followed or preceded by column name. You can also put column names within the parenthesis of DESC keyword. So, there are two variants of using DESC:

  • DESC(col_name);
  • col_name DESC;

For example, we can order cars by mileage, but this time in descending order.

123
SELECT * FROM audi_cars ORDER BY mileage DESC
copy

Please note, that there is also ASC keyword in SQL used for ascending sorting. Since default sorting in SQL is in ascending order, this keyword is rarely used.

Завдання

From the audi_cars table extract all the cars sorted by column tax in descending order.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 4. Розділ 2
Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
some-alt