codingtcher.com
Theme Night
Home
Login

Sql Order By

Home » Sql » Sql Order By

sort by sql

SELECT * FROM table_name ORDER BY col1 ASC;				-- ASCending is default
SELECT * FROM table_name ORDER BY col1 DESC;			-- DESCending
SELECT * FROM table_name ORDER BY col1 DESC, col2;	 	-- col1 DESC then col2 ASC

SQL ORDER BY Clause

SELECT *
FROM Customers
ORDER BY first_name;

sorting desc in sql

order by statement in sql

order by sql

//this_for_descending_order.. 
 SELECT * FROM TableName ORDER BY columnName DESC;
 // this_for_ascending_order..
SELECT * FROM TableName ORDER BY columnName ASC;

SQL ORDER BY With WHERE

SELECT last_name, age
FROM Customers
WHERE NOT country = 'UK'
ORDER BY last_name DESC;

Sql Related Post