SQL ORDER BY

SQL ORDER BY is used to filter results by ascending or descending order in SQL SELECT statements. We can add ORDER BY right after the table name or after WHERE clause in the SQL statement.

Sample SQL statement for SQL ORDER BY in SELECT SQL.

In Ascending Order

SELECT * FROM table_name ORDER BY column1 ASC;

In Descending Order

SELECT * FROM table_name ORDER BY column1 DESC;

Sample SQL statement for SQL ORDER BY in SELECT SQL with WHERE clause.

In Ascending Order

SELECT * FROM table_name WHERE column2 = value ORDER BY column1 ASC;

In Descending Order

SELECT * FROM table_name WHERE column2 = value ORDER BY column1 DESC;

Vivek Vengala
 

Vivek Vengala is a Online Entrepreneur, Web Developer from Hyderabad India.

Click Here to Leave a Comment Below 0 comments

Leave a Reply:

x

Join My Facebook Group to Receive Coding Tutorial for Free

email-subsribe