sql order by alphabetical code example

Example 1: how to sort names in alphabetical order in sql

SELECT id,  
    first_name,
    last_name, 
  FROM customer
  ORDER BY last_name ASC;

Example 2: sql order by alphabetical

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 ASC;	-- col1 DESC then col2 ASC

Example 3: order by in sql

ORDER BY: is for sorting result
either in descending or ascending order.

Tags:

Misc Example