Sorting Results with ORDER BY

Introduction

A SELECT statement returns a set of rows, and unless you say otherwise, the database makes no promise about the order in which those rows come back. The ORDER BY clause is how you take control of that sequence, telling the database to present results sorted by one or more columns, ascending or descending. It is the last major clause evaluated in a query, which is why it can reference column aliases and even column positions that earlier clauses cannot.

In this module you are building complex queries with joins, grouping, and subqueries. Sorting is what makes those results readable and usable: a grouped sales summary is far more informative when ordered from highest total to lowest, and a filtered customer list is easier to scan when ordered by last name then first name. You will also see that sorting behaves differently depending on data type — numbers sort numerically, text sorts by collation rules, and dates sort chronologically — and that NULL values need special attention.

As you watch, pay attention to the exact syntax (ASC is the default and can be omitted, DESC must be stated explicitly), to how a second or third sort column acts as a tiebreaker, and to how sorting interacts with row limits such as LIMIT or TOP. Also note where sorting by column position is convenient and where it becomes fragile if the SELECT list changes.

Video 1: Mastering ORDER BY in SQL | Sort Data Easily (Ascending, Descending & Multiple Columns)

PythonPythonME · 13:42 · 25 views · 1y ago · captions — Watch on YouTube

About this video

A beginner-oriented walkthrough of the ORDER BY clause that, based on its title and description, steps through sorting in ascending order, descending order, and across multiple columns. Expect demonstrations of the basic syntax and how the sort direction keyword attaches to each column individually.

Why this video

It maps directly onto the core subtopics here — purpose of ORDER BY, ASC, DESC, and multi-column sorting — and its slow, beginner-friendly pacing makes it a good first watch before the more advanced material.

Video 2: SQL ORDER BY with UNION, LIMIT/TOP & NULL Handling | Advanced Sorting Tutorial

PythonPythonME · 17:29 · 26 views · 1y ago · captions — Watch on YouTube

About this video

This follow-up video from the same channel addresses ORDER BY in more complicated situations: how sorting applies to the combined result of a UNION, how it interacts with LIMIT or TOP to produce top-N results, and how NULL values are positioned in a sorted list. These are the scenarios where sorting behavior commonly surprises students.

Why this video

It extends the basics into the complex-query context of this module and covers the NULL and data-type edge cases that the topic summary calls out, which simple tutorials usually skip.

Video 3: Learn Basic SQL in 15 Minutes | Business Intelligence For Beginners | SQL Tutorial For Beginners 1/3

Adam Finer - Learn BI · 17:40 · 3,545,042 views · 5y ago · captions — Watch on YouTube

About this video

A widely viewed introductory SQL lesson that covers the fundamentals of writing queries against a sample database, including SELECT, filtering, and sorting output. It is the first part of a three-part beginner series using a downloadable SQLite database and query files so you can follow along hands-on.

Why this video

With millions of views and a well-established business-intelligence instructor, it provides a reliable refresher that places ORDER BY in the context of a full query, which is useful if your SELECT and WHERE skills feel rusty before tackling the sorting specifics.

How These Videos Support the Learning Outcomes

These videos reinforce the module outcomes by showing how the final presentation step of a query fits with the clauses you are constructing. Sorted output makes the results of JOIN queries (MO1) and WHERE filters (MO2) readable and verifiable, and ordering an aggregated result set is how GROUP BY and HAVING summaries become meaningful rankings (MO3, MO4). The advanced video's treatment of ORDER BY with UNION, LIMIT/TOP, and NULLs supports the multi-step query construction expected in MO5, where a correctly ordered and limited result is often the point of the subquery in the first place.

About These Videos

These videos were chosen from YouTube on October 2, 2026. Each has captions; the player turns them on. Videos on YouTube can be changed or removed — if one no longer plays, tell your instructor. If a player does not appear, use its Watch on YouTube link.