Sorting by multiple columns
Can we sort by multiple columns at once? And what does it mean? Assume, we firstly sort by one column. If there are some matches in this column, then sorting by another column will sort within this sub-group.
To make SQL sort by multiple columns at once just write ORDER BY
followed by column names you want to sort by separated with a comma. For example, we can sort the entire audi_cars
table firstly by engine size (enginesize
) in descending order and then by price in ascending.
123SELECT * FROM audi_cars ORDER BY enginesize DESC, price
Swipe to start coding
Sort audi_cars
table by mileage
in ascending order and then by price
in descending order.
Solución
¡Gracias por tus comentarios!
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Awesome!
Completion rate improved to 2.63Awesome!
Completion rate improved to 2.63
Sorting by multiple columns
Can we sort by multiple columns at once? And what does it mean? Assume, we firstly sort by one column. If there are some matches in this column, then sorting by another column will sort within this sub-group.
To make SQL sort by multiple columns at once just write ORDER BY
followed by column names you want to sort by separated with a comma. For example, we can sort the entire audi_cars
table firstly by engine size (enginesize
) in descending order and then by price in ascending.
123SELECT * FROM audi_cars ORDER BY enginesize DESC, price
Swipe to start coding
Sort audi_cars
table by mileage
in ascending order and then by price
in descending order.
Solución
¡Gracias por tus comentarios!
single
Awesome!
Completion rate improved to 2.63
Sorting by multiple columns
Desliza para mostrar el menú
Can we sort by multiple columns at once? And what does it mean? Assume, we firstly sort by one column. If there are some matches in this column, then sorting by another column will sort within this sub-group.
To make SQL sort by multiple columns at once just write ORDER BY
followed by column names you want to sort by separated with a comma. For example, we can sort the entire audi_cars
table firstly by engine size (enginesize
) in descending order and then by price in ascending.
123SELECT * FROM audi_cars ORDER BY enginesize DESC, price
Swipe to start coding
Sort audi_cars
table by mileage
in ascending order and then by price
in descending order.
Solución
¡Gracias por tus comentarios!