Introduction
We use ASC and DESC to sort data in a list from smallest to largest or largest to smallest. This helps us find information quickly.
SELECT column1, column2 FROM table_name ORDER BY column1 ASC; SELECT column1, column2 FROM table_name ORDER BY column1 DESC;
SELECT name, price FROM products ORDER BY price ASC;
SELECT name, created_at FROM orders ORDER BY created_at DESC;
SELECT student_name, score FROM scores ORDER BY score DESC;
SELECT city FROM cities ORDER BY city ASC;
CREATE TABLE employees ( id INT, name VARCHAR(50), salary INT ); INSERT INTO employees VALUES (1, 'Alice', 5000), (2, 'Bob', 3000), (3, 'Charlie', 7000); SELECT name, salary FROM employees ORDER BY salary DESC;
ASC keyword do in a MySQL ORDER BY clause?employees by the salary column in descending order?products with column price, what will be the order of prices returned by this query?SELECT price FROM products ORDER BY price DESC;
students by age in descending order:SELECT * FROM students ORDER age DESC;
orders sorted first by order_date ascending, then by total_amount descending. Which query correctly achieves this?Pass the test and this pattern moves unknown