|
SQL Home
SQL TutorialIntroductionSQL Syntax SQL Select SQL Where SQL Order By SQL Top SQL Distinct SQL In SQL Alias SQL Join SQL Inner Join SQL Outer Join SQL Insert SQL Update SQL Delete SQL Functions SQL Count SQL Create SQL Create Database SQL Create Table SQL Create Index SQL Alter Table SQL Summary Got a MySpace Page?Get "www.yourname.com" for your MySpace page. Learn how >>. |
SQL Order ByUsing a SQL SELECT statement can retreive many hundreds or even thousands of records. In some cases you might find it useful to sort the records by a given column. For example, when selecting records from the Individual table, you might like to sort them by the LastName column. SQL statement
Source Table
Result
Descending OrderBy default, ORDER BY sorts the column in ascending order - that is, from lowest values to highest values. You could also explicitly state this using the ASC keyword, but it's not necessary. If you want highest values to appear first, you can use the DESC keyword. SQL statement
Result
Sorting By Multiple ColumnsYou can sort by multiple columns by stating each column in the ORDER BY clause, separating each column name with a comma. SQL will first order the results by the first column, then the second, and so on for as many columns that are included in the ORDER BY clause. SQL statement
Result
Enjoy this website?
Oh, and thank you for supporting Quackit! |
FREE Hosting!With every domain name you register with ZappyHost, you get FREE (ad supported) hosting.PLUS you get:
Featured Template:
(Build your websites in minutes!) |