O'Reilly logo

Sams Teach Yourself Microsoft by Ben Forta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Lesson 5. Sorting Retrieved Data

In this lesson, you will learn how to use the SELECT statement’s ORDER BY clause to sort retrieved data as needed.

Sorting Data

As you learned in the last lesson, the following SQL statement returns a single column from a database table. But look at the output. The data appears to be displayed in no particular order at all.

Input Image

SELECT prod_nameFROM products;

Output Image

prod_name--------------.5 ton anvil1 ton anvil2 ton anvilDetonatorBird seedCarrotsFusesJetPack 1000JetPack 2000

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required