SQL ASC Keyword
The ASC
keyword in SQL is used with the ORDER BY
clause to sort the result set in ascending order. This means values will be arranged from the lowest to the highest (A–Z for text, 0–9 for numbers, and earliest to latest for dates).
If no sorting keyword is specified, ASC
is used by default.
SQL ASC Syntax
SQL
x
1
SELECT column1, column2, ...
2
FROM table_name
3
ORDER BY column_name ASC;
SQL ASC Example with Patients Table
The following SQL statement selects all columns from the Patients
table, sorted by the last_name
column in ascending order.
This query will return all patient records and arrange them alphabetically by their last names, from A to Z.
SQL
1
1
SELECT *
2
FROM Patients
3
ORDER BY last_name ASC;
