SQL ASC Keyword

The ASC keyword in SQL is used with the ORDER BY clause to sort the result set of a query in ascending order (from lowest to highest, or alphabetically from A to Z).



ASC: Definition and Usage

Ascending order is the default sorting behavior of ORDER BY, so you don't actually *need* to include ASC; however, it's good practice to explicitly state it for clarity and readability in your code. This makes your SQL queries easier to understand and maintain, especially when working with complex sorts.

Syntax

Syntax

SELECT column1, column2, ...
FROM table_name
ORDER BY column_name ASC;
      

Example

Sorting Customer Names in Ascending Order

This query retrieves all columns from the 'Customers' table and sorts the results alphabetically by the 'CustomerName' column in ascending order (A to Z).

Syntax

SELECT * FROM Customers
ORDER BY CustomerName ASC;
      
Output

(The Customers table data will be displayed here, sorted alphabetically by CustomerName from A to Z)
      

**Note:** The output will vary depending on the data present in your `Customers` table. This example assumes that the `Customers` table exists and has a `CustomerName` column.