SQL Query to use ORDER BY clause

The default order of rows returned for a result table varies depending upon the specific nature of the query. However, generally you can assume that the order of result table rows is random. If a specific order is required then one must include the optional ORDER BY clause.

             
               SELECT [column(s)]
               FROM [table(s)]
               WHERE [row(s) to select]
               GROUP BY [column(s) for summaries]
               HAVING [groups to select]
               ORDER BY (Cols to sort)

The ORDER BY clause is almost always placed at the end of the SELECT statement (although some advanced statement structures beyond the scope of this course could alter this general rule). The default sort order is ascending if the ORDER BY clause is omitted.

Comments

Popular posts from this blog

Top myths for NULL value in SQL Queries