From the course: SQL Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Sorting query results

Sorting query results - SQL Tutorial

From the course: SQL Essential Training

Sorting query results

- [Instructor] We are doing really great. We have just formatted our brand new query and have aliased the columns, and now we're speaking in the language of the business. So our query looks pretty good, but we can still do a few things to improve our query result. Now WSDA Music Management loves our report, but they would like to have the results sorted by last name. How would we go about achieving this in SQL? Well, our first step is to include a brand new clause which comes after the from clause called the order by clause. By placing that clause there, and then specifying the column, we now want to order by which in this case is the last name, we can now sort our results. Now when it comes to sorting, we can go in one of two different ways. We can either sort ascending which is A to Z or descending order. And the ascending order sort is actually the default sort in SQL. So by me clicking on run, at this point…

Contents