From the course: SQL Server 2008 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Sorting your output - SQL Server Tutorial
From the course: SQL Server 2008 Essential Training
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 that we have…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
(Locked)
Introduction to Transact-SQL3m 43s
-
(Locked)
Using SELECT statements7m 16s
-
(Locked)
Changing the default database2m 21s
-
(Locked)
Creating conditions in SQL8m 10s
-
(Locked)
Sorting your output3m 23s
-
(Locked)
Using aggregate functions7m 12s
-
(Locked)
Finding unique values2m 14s
-
(Locked)
Joining multiple tables together8m
-
(Locked)
Using subqueries9m 33s
-
(Locked)
Viewing execution plans3m 37s
-
(Locked)
-
-
-
-
-
-
-
-
-