Wednesday 29 May 2013

ORDER BY Clause in SQL


  • Sort rows with the ORDER BY clause
    • ASC:  ascending order (Default)
    • DESC:  descending order
  • The ORDER BY clause comes last in the SELECT statement.
  • We can Sort the rows by the name of the column which may not be present in the sorted list. (see second example)
Example:

Example: Here names of employees are sorted according to salary but salary column is not present in the sorting list. 



No comments:

Post a Comment