

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: LIMIT
incomplete
2: Limit Quiz
incomplete
3: ORDER BY
incomplete
4: ORDER BY Quiz
incomplete
5: ORDER BY and LIMIT
incomplete
6: Query Practice – Security Breach
incomplete
This lesson's interactive features are locked, please to keep using them
SQL also offers us the ability to sort the results of a query using ORDER BY. By default, the ORDER BY keyword sorts records by the given field in ascending order, or ASC for short. However, ORDER BY does support descending order as well with the keyword DESC.
This query returns the name, price, and quantity fields from the products table sorted by price in ascending order:
SELECT name, price, quantity FROM products
ORDER BY price;
This query returns the name, price, and quantity of the products ordered by quantity in descending order:
SELECT name, price, quantity FROM products
ORDER BY quantity DESC;
Write a query that lists all the records in the transactions table where:
amount is BETWEEN 10 and 80 dollars.amount in descending order.Remember, BETWEEN is inclusive on both ends. The condition WHERE quantity BETWEEN 5 AND 10, for example, would include records where quantity is 5, 10, or anywhere between.