SQL Order By
SQL Order By Example One
Select Film_Title, Thespian_First_Name, Thespian_Last_Name
From Thespian_Film_Table
Where Film_Title in ("Blade Runner", "Brazil", "The Matrix")
Order by Film_Title;
Blade Runner, Harrison, Ford Blade Runner, Rutger, Hauer Blade Runner, Sean, Young Blade Runner, Daryl, Hannah Brazil, Jonathan, Pryce Brazil, Robert, DeNiro Brazil, Michael, Palin The Matrix, Keanu, Reeves
SQL Order By Example Two
Select Film_Title, Thespian_First_Name, Thespian_Last_Name
From Thespian_Film_Table
Where Film_Title in ("Blade Runner", "Brazil", "The Matrix")
Order by Thespian_Last_Name;
Brazil, Robert, DeNiro Blade Runner, Harrison, Ford Blade Runner, Daryl, Hannah Blade Runner, Rutger, Hauer Brazil, Michael, Palin Brazil, Jonathan, Pryce The Matrix, Keanu, Reeves Blade Runner, Sean, Young
SQL Order By Example Three
Select Film_Title, Thespian_First_Name, Thespian_Last_Name
From Thespian_Film_Table
Where Film_Title in ("Blade Runner", "Brazil", "The Matrix")
Order by Thespian_Last_Name Descend;
Blade Runner, Sean, Young The Matrix, Keanu, Reeves Brazil, Jonathan, Pryce Brazil, Michael, Palin Blade Runner, Rutger, Hauer Blade Runner, Daryl, Hannah Blade Runner, Harrison, Ford Brazil, Robert, DeNiro
Also Note: For some DBMSs you must specify desc instead of descend when you want descend.
| Sign In |
| to add your own comment |
| Comment by TheMadProfessor Rate this Comment |
Another option when using ORDER BY is to specify the result table column number instead of the field name. To demonstrate, your example # 2 could have been written as:
|
| Comment by Larry Rate this Comment |
Your information on the ORDER BY clause has a mistake. When using Microsoft SQL Server 7.0, the clause DESCEND causes an error. The correct "key word" as set forth by Microsoft is DESC.
|