ASC
Example
Section titled “Example”SELECT * FROM EmployeesORDER BY LastName ASC;Output
Section titled “Output”| EmployeeID | LastName | FirstName | Department || ---------- | -------- | --------- | ---------- || 4 | Adams | Amy | HR || 2 | Brown | Brian | Sales || 3 | Clark | Chris | IT || 1 | Davis | David | Marketing |Explanation
Section titled “Explanation”In the SQL code above, SELECT * FROM Employees is used to retrieve all records from the Employees table. The ORDER BY LastName ASC clause is used to sort the records in ascending order based on the LastName column. The resulting output contains all employee records, organized in an ascending order with respect to the last names.
Example
Section titled “Example”SELECT *FROM employeesORDER BY last_name ASC;Output
Section titled “Output”last_name | first_name | hire_date----------|------------|------------Adams | John | 2003-07-07Allen | Mark | 2003-08-20Blake | Marion | 2003-03-11Clark | Ruben | 2003-06-14Davis | Rafael | 2003-09-30Explanation
Section titled “Explanation”The given SQL statement fetches all records from the employees table and orders them by the last_name column in ascending (ASC) order.
Example
Section titled “Example”SELECT * FROM EmployeesORDER BY LastName ASC;Output
Section titled “Output”| EmployeeID | LastName | FirstName | Title ||------------|----------|-----------|-------------|| 1 | Doe | Jane | Manager || 2 | Johnson | John | Sales || 3 | Smith | Steve | IT Specialist |Explanation
Section titled “Explanation”The SQL statement selects all records from the Employees table and orders them in ascending order (ASC) by the LastName column. The output displays EmployeeID, LastName, FirstName and Title of all employees, sorted by LastName in alphabetical order A-Z (as arranged by ASCII values).
Example
Section titled “Example”SELECT *FROM EmployeesORDER BY Salary ASC;Output
Section titled “Output”| Employee_ID | First_Name | Last_Name | Salary ||-------------|------------|-----------|--------|| 1 | John | Doe | 3000 || 3 | Jane | Smith | 3200 || 2 | Tim | Taylor | 3500 |Explanation
Section titled “Explanation”The SQL code selects all columns from the ‘Employees’ table and orders the resulting records in ascending order by the ‘Salary’ column. In the output, the Employee records are ordered from the lowest to the highest salary.
Example
Section titled “Example”SELECT * FROM EmployeesORDER BY Last_Name ASC;Output
Section titled “Output”| ID | Last_Name | First_Name | Salary ||----|-----------|------------|--------|| 1 | Anderson | John | 45000 || 2 | Brown | Lucy | 60000 || 3 | Davis | Kate | 48000 || 4 | Evans | Mike | 55000 |Explanation
Section titled “Explanation”The SQL code provided above selects all records from the “Employees” table and then sorts the output in ascending (ASC) order based on the “Last_Name” column. This means that the records are displayed alphabetically from A-Z based on the last names of the employees.