Opening
Millions of Matches, One Page

- A findable screenshot of a Google search results page showing a search query, a results-count line, several results on the first screen, and page-navigation controls near the bottom. Keep the screen focused on the contrast between many reported matches and a limited visible set; do not add explanatory annotations.
Slide 1
Distinct Values and Sort Direction

- SELECT DISTINCT city FROM visits removes repeated city values from the result; if the selected values include Austin, Austin, and Dallas, the output contains Austin and Dallas once each.
- ORDER BY city ASC places text values in ascending alphanumeric order, such as Austin, Dallas, Seattle; ASC is also the default direction when no direction is written.
- ORDER BY count DESC places larger numbers first, such as 91, 64, 28; sorting changes row order but does not by itself remove duplicate values.
- DISTINCT
- — Removes repeated selected values from query results.
- ASC
- — Orders values from lower to higher or A to Z.
- DESC
- — Orders values from higher to lower or Z to A.
Check for understanding
Check Your Understanding
Slide 2
Control the Page with LIMIT and OFFSET

- LIMIT sets the maximum number of rows returned, so LIMIT 3 returns no more than three rows even when more records match.
- OFFSET skips a specified number of rows from the ordered result before the remaining rows are returned; OFFSET 2 skips the first two rows.
- This pagination query—SELECT title FROM books ORDER BY title ASC LIMIT 3 OFFSET 2;—returns Cinder, Dune, and Emma from the ordered list A Wrinkle in Time, Beloved, Cinder, Dune, Emma, Frankenstein.
- LIMIT
- — Caps the number of rows returned.
- OFFSET
- — Skips a specified number of rows before returning results.
- Pagination
- — Divides a larger result set into navigable pages.
Check for understanding
Check Your Understanding
Slide 3
Worked Case: Unique Products in Reverse Alphabetical Order

- An inventory table has five product values in order: Mug, Notebook, Mug, Binder, Notebook; the repeated Mug and Notebook values come from separate records.
- Read SELECT DISTINCT product FROM inventory ORDER BY product DESC; by keeping one of each selected value, then arranging the results from later to earlier alphabetically: Notebook, Mug, Binder.
- Changing DESC to ASC gives Binder, Mug, Notebook; removing DISTINCT allows the repeated Mug and Notebook values to remain in the sorted result.
- Selected columns
- — The columns named after SELECT in a query.
- Duplicate value
- — A selected value that appears more than once.
Check for understanding
Check Your Understanding
Slide 4
Worked Case: Navigate a Ticket List

- A support dashboard lists ticket IDs 208, 207, 206, 205, and 204 by created_at DESC, from newest to oldest.
- SELECT ticket_id FROM tickets ORDER BY created_at DESC LIMIT 2 OFFSET 2; skips IDs 208 and 207, then returns 206 and 205.
- ORDER BY determines row sequence, DISTINCT removes repeated selected values, LIMIT sets the maximum page size, and OFFSET sets how many ordered rows to skip.
- LIMIT
- — Sets the maximum number of returned rows.
- OFFSET
- — Sets the number of ordered rows to skip.
- ORDER BY
- — Sets the sequence of rows in query results.
Check for understanding
Check Your Understanding
Check for understanding
Solo Run: Control Query Results
Exit check