INNER, LEFT, RIGHT, and FULL joinsPlannedSelf joins and many-to-many dataPlannedSubqueries and correlated subqueriesPlannedUNION, INTERSECT, and EXCEPTPlanned
Designing reliable schemas
CREATE TABLE and schema designPlannedConstraints and data integrityPlannedNormalization and intentional denormalizationPlannedViews and materialized viewsPlanned
Writing and protecting data
INSERT, UPDATE, and DELETEPlannedUpserts and conflict handlingPlannedTransactions and savepointsPlannedIsolation, locks, and concurrencyPlanned
Performance and administration
Indexes and access pathsPlannedEXPLAIN and query plansPlannedQuery tuning patternsPlannedBackups, restores, and migrationsPlanned
Security and production workflow
Users, roles, and least privilegePlannedPreventing SQL injectionPlannedStored procedures, functions, and triggersPlannedProduction data projectPlanned
Reading and filtering data · Lesson 08 130 min
Text, Dates, Patterns, and Conditional Results
Real queries rarely stop at exact equality. Editors search text, reports select a date window, and interfaces turn raw values into labels. This lesson combines those needs without changing the stored article rows or hiding the rules that produced a result.
Transform values, then explain the result
TextUse LOWER, UPPER, and TRIM for readable, consistent output.
PatternsUse LIKE with wildcards that match the intended text shape.
DatesUse explicit boundaries that include every day in a reporting window.
ConditionsUse CASE and COALESCE to name a result without changing the source.
Nine rows include drafts, missing authors, and dates around September.
FILTERSeptember SQL articlesLIKE + date range + status
Only two rows pass all three rules.
RESULTReadable digestdisplay_author · reach_label
Computed labels are returned without modifying stored columns.
Text functions shape a result without changing stored values
LOWER(title) produces a lowercase value useful for a simple search comparison. UPPER(category) can produce an uppercase label. TRIM(author_name) removes leading and trailing spaces, so the deliberately padded author on CSS Layouts displays cleanly. These functions create result values; they do not rewrite the table. Function names are common across SQL systems, but Unicode case handling and collations can differ.
SQL BROWSER RUNNER
Normalize a display value
Compare each stored title and author with a lowercase title and trimmed author in the result.
Edit the query, predict the rows it will return, then run it.
LIKE matches a text pattern
The percent sign in LIKE 'sql%' means zero or more characters after sql. Using LOWER(title) makes this SQLite exercise find titles beginning with SQL regardless of their ASCII letter case. It matches SQL Basics, SQL Patterns, and SQL Window Functions. It does not match Learning SQL because SQL appears at the end of that title.
Edit the query, predict the rows it will return, then run it.
Percent and underscore mean different things
% matches any sequence of characters, including an empty sequence. _ matches exactly one character. The first query below finds every slug starting with sql-. The second asks for sql-, any one character, then a, then anything else. That matches sql-basics and sql-patterns, but not sql-window-functions. For a literal percent or underscore, use an explicit escape convention supported by your SQL dialect.
SQL BROWSER RUNNER
Compare two LIKE wildcards
Inspect both result sets to see how a one-character wildcard narrows a prefix.
Edit the query, predict the rows it will return, then run it.
A half-open date range covers a full month
This SQLite runner stores dates as fixed-width ISO text in YYYY-MM-DD form. With valid, consistently formatted dates, lexical comparison follows calendar order. The September query uses published_on >= '2026-09-01' and published_on < '2026-10-01'. It includes September 30 but excludes October 1 and the August article. The upper bound is exclusive, which also works well when a production column includes times throughout the final day.
SQL BROWSER RUNNER
Read all September publications
Find the five published articles whose ISO dates fall within September 2026.
Edit the query, predict the rows it will return, then run it.
A missing date needs IS NULL
The draft JavaScript DOM article has no publication date. It does not match a September comparison because comparing NULL with a date yields unknown. Use published_on IS NULL to find unscheduled articles and IS NOT NULL to select rows with a date. An empty string would be a different stored value and should not be used as a substitute for missing data.
SQL BROWSER RUNNER
Separate scheduled from unscheduled articles
Compare the one missing publication date with eight dated rows.
Edit the query, predict the rows it will return, then run it.
CASE turns conditions into a readable result label
A searched CASE checks WHEN conditions in order and returns the value from the first true branch. Here 1,000 or more views means Popular, 500 through 999 means Growing, and anything else means New. The order matters: test the higher threshold first. END AS reach_label names the calculated result column; it does not add a stored column. Include an ELSE when unmatched rows should get a deliberate label rather than NULL.
SQL BROWSER RUNNER
Classify article reach
Turn raw view counts into clear Popular, Growing, and New result labels.
Edit the query, predict the rows it will return, then run it.
COALESCE supplies a fallback for NULL
COALESCE(TRIM(author_name), 'Editorial team') returns the trimmed author when present and the fallback when the author is NULL. SQL Patterns and SQL Window Functions have missing authors, so both display Editorial team. A blank string is not NULL; COALESCE alone does not treat empty text as missing. If blank input is invalid, reject or normalize it at the data boundary.
SQL BROWSER RUNNER
Display a fallback author
Fill missing author labels while preserving the stored NULL values.
Edit the query, predict the rows it will return, then run it.
Compose transformations without hiding the source rule
Queries can transform several output values while keeping the filter explicit. The example uppercases Data and Web category labels, then uses CASE to display Unscheduled for a missing publication date. It still returns the draft article because the filter checks category, not status. Read WHERE to learn which rows qualify and the SELECT list to learn how those rows will appear.
SQL BROWSER RUNNER
Shape a readable article result
Combine a category filter, an uppercase label, and a missing-date label.
Edit the query, predict the rows it will return, then run it.
Common text and date mistakes
LIKE 'sql'
Missing wildcard
That pattern matches only the whole value sql. Add % for a prefix or substring search.
LIKE 'sql_%'
Accidental wildcard
An underscore means any one character. Escape it when you need a literal underscore.
published_on <= '2026-09-30'
Incomplete final day
For timestamp values, a midnight upper bound can exclude later hours on September 30. Use an exclusive October 1 bound.
COALESCE(author_name, fallback)
Blank is not NULL
An empty or whitespace-only string stays present unless you normalize or reject it deliberately.
Independent lab: build a September SQL digest
Return published articles whose titles start with SQL and whose publication dates fall in September 2026. Include a readable author label and a reach label: Popular for at least 900 views, Growing otherwise. The starter query should return SQL Patterns first and SQL Window Functions second. Change the date range to include August, then explain why SQL Basics joins the result. Finally, make the reach threshold 1,000 and predict which label changes.
SQL BROWSER RUNNER
Publish a two-article SQL digest
Combine text matching, a half-open date window, COALESCE, CASE, and stable ordering.
Edit the query, predict the rows it will return, then run it.
Lesson review
LOWER, UPPER, and TRIM transform output text without changing stored values. LIKE supports sequence and single-character wildcards. A half-open date range makes month boundaries clear, while IS NULL handles missing dates. CASE chooses a result from ordered conditions, and COALESCE provides a fallback for NULL. Keep the source filter visible and test the edge dates and missing values before trusting a report.
I can distinguish a transformed result from a stored value.
I can explain what % and _ mean in a LIKE pattern.
I can filter a month with an inclusive start and exclusive next-month boundary.
I can test a missing date with IS NULL.
I can order CASE branches from specific to general.
I can use COALESCE for NULL without confusing it with blank text.
KNOWLEDGE CHECK
Check text, date, and conditional logic
Answer all ten questions, then rerun any example whose boundary or output surprised you.