28
Dec
If you want to sort data, then you have to use order by clause. If you want to sort data in ascending order, then you have to use the following query:
Pattern:
select * from table_name order by column_name ASC;
If you want to sort data in ascending order, then you have to use following query:
Pattern:
select * from table_name order by column_name DESC;
Example:
Write a query to sort employees in descending order by their salary.
SELECT * FROM employees ORDER BY salary DESC;
Write a query to sort employees in ascending order by their name.
SELECT * FROM employees ORDER BY FirstName ASC;
Leave a Reply