Sorting data

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;
about author

admin

salmansrabon@gmail.com

If you like my post or If you have any queries, do not hesitate to leave a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *