Sorting your output


show more Sorting your output provides you with in-depth training on Business. Taught by Simon Allardice as part of the SQL Server 2008 Essential Training show less
please wait ...

Sorting your output

So let's take the idea of filtering our data a bit further. In this very simple SQL statement I am retrieving all the product information from the Product table here, and I have got a lot of different things in different colors, with names and Product IDs and list prices. What I would like to do is go buy the cheapest to the most expensive. Well it's yet another SQL clause and we'll put it right at the end of the SQL statement, and I'll just put in Order By. Well, order by what? Well, in this case I'd like to Order By ListPrice.

I hit F5 to execute that and we are going with the ordered ListPrice. By default it will be ascending. If we want to make it descending we just type-in the word DESC afterwards, hit Execute and now we have by ListPrice descending. You can if you want to pick multiple columns to order on, so I could order for example by Color, ListPrice, and what this would do is order by color ascending and then ListPrice descending within it. So if I execute ...

Sorting your output
Video duration: 3m 23s 6h 54m Beginner

Viewers:

Sorting your output provides you with in-depth training on Business. Taught by Simon Allardice as part of the SQL Server 2008 Essential Training

Subjects:
Business Developer IT
Software:
SQL Server
Author:
please wait ...