web 2.0

Learning About ORDER BY clause

ORDER BY clause used to sort the results based on one or more columns. Ordering can be ascending (ASC) or descending (DESC), the default is ASC. If sorting by several columns, nested sequencing process.

For example we will display the employee data was sorted by country:
SELECT country, EmployeeID, LastName, FirstName FROM Employees ORDER BY Country
Data will be sorted based on the Country. Notice, how the LastName, LastName whether in each country will be sorted? No, if we wish for a country such data was sorted by LastName, you must declare two fields in the ORDER BY:

SELECT country, EmployeeID, LastName, FirstName FROM Employees ORDER BY Country, LastName

0 comments:

Post a Comment