On the NHANES 2017-2018 database in SQLite 3.49.1, a scalar subquery that returns several rows silently yields its first row in SQLite (one of 427 people aged 80) and an error in PostgreSQL. IN and EXISTS are semi-joins: both count 1,210 statin users where a plain join counts 1,217 rows. NOT IN against a subquery that holds a NULL returns 0 drugs where NOT EXISTS returns 475; they agree when both columns are NOT NULL, and NOT EXISTS is the safe anti-join. A correlated subquery, its window-function rewrite and a grouped join all count 2,368 adults above their group mean, but differ when a grouping key is NULL (2,159 against 2,284 by education). Recursive common table expressions generate unstored rows, such as empty histogram bins.
Of the 5,247 adults with a measured blood pressure, how many are above the average? The question has two steps, compute the average and then compare each adult with it, and SQL lets the first step be written inside the second:
SELECT COUNT(*) AS above_mean
FROM adult_bp
WHERE sbp > (SELECT AVG(sbp) FROM adult_bp); -- 2,247
The parenthesized SELECT is a subquery. It returns the mean systolic pressure, 126.36 mm Hg, and the outer query counts the 2,247 adults above it. (adult_bp is a view with one row per adult: person number, sex, age and mean systolic pressure over up to three readings, as built in Aggregate Functions.)
A query's result is a table (Simple SQL Queries), and a subquery is a query used wherever a value, a list or a table is expected. This article covers the three uses, the difference between a subquery that runs once and one that runs for every row, the EXISTS and NOT EXISTS tests and the trap in NOT IN, and common table expressions, which name subqueries and, in their recursive form, let SQL generate rows it does not store.
Scalar subqueries
A subquery that returns one row and one column is a scalar subquery and can be used anywhere a single value can: in WHERE, as above, or in the SELECT list, where it adds the same value to every row:
SELECT seqn, sbp, sbp - (SELECT AVG(sbp) FROM adult_bp) AS above_mean
FROM adult_bp;
The first adult in the file, person 93705, has a mean systolic pressure of 202 and is 75.64 above the mean.
What happens when a scalar subquery does not return exactly one row differs between databases. With no rows, the value is NULL in SQLite and in PostgreSQL. With more than one row, PostgreSQL, following the standard, raises an error: its documentation states that "It is an error to use a query that returns more than one row or more than one column as a scalar subquery" (PostgreSQL Global Development Group, n.d.-a). SQLite does not: "The value of a subquery expression is the first row of the result from the enclosed SELECT statement" (SQLite, n.d.-a). So
SELECT (SELECT seqn FROM person WHERE age = 80); -- 93768
returns one person number, without complaint, although 427 people are aged 80. A subquery meant to look up one value by a key that turns out not to be unique gives a silently arbitrary answer in SQLite and an error elsewhere. Aggregating inside the subquery (MAX, COUNT) or filtering on a primary key makes the single row certain.
IN and EXISTS
Subqueries that return a list
A subquery after IN returns a column of values, and the outer row is kept if its value is among them. People taking a statin:
SELECT COUNT(*) FROM person
WHERE seqn IN (SELECT p.seqn
FROM prescription AS p JOIN drug AS d USING (drug_id)
WHERE d.name LIKE '%STATIN' AND d.name <> 'NYSTATIN'); -- 1,210
(The name pattern and the exclusion of nystatin, an antifungal, are explained in Special Operators and Clauses.) The subquery returns the person number of every statin prescription; the outer query keeps each person once, however often their number appears in the list.
EXISTS
EXISTS (subquery) is true when the subquery returns at least one row; what the rows contain does not matter, so the subquery is often written SELECT 1 (SQLite, n.d.-a). The same question in this form:
SELECT COUNT(*) FROM person AS pe
WHERE EXISTS (SELECT 1
FROM prescription AS p JOIN drug AS d USING (drug_id)
WHERE p.seqn = pe.seqn
AND d.name LIKE '%STATIN' AND d.name <> 'NYSTATIN'); -- 1,210
The subquery refers to pe.seqn, a column of the outer query, so it is evaluated for each person; it is a correlated subquery, discussed below. IN asks "is this value in that list?"; EXISTS asks "is there a matching row?". For most questions they are interchangeable, and modern planners often turn one into the other.
Their relation to joins
Both forms are semi-joins: they keep rows of the outer table that have a match, each at most once. An inner join is not a semi-join, because it returns a row for every match:
| Query | Result |
|---|---|
IN (subquery) |
1,210 people |
EXISTS (subquery) |
1,210 people |
JOIN, COUNT(*) |
1,217 rows |
JOIN, COUNT(DISTINCT pe.seqn) |
1,210 people |
A few people report more than one statin prescription, and the join repeats them, adding seven rows. For a count the repair is DISTINCT, but for anything averaged over the joined rows the duplicates change the answer. The mean total cholesterol of statin users with a cholesterol result is 169.50 mg/dL over 1,088 people with IN, and 169.41 over 1,093 rows with a join, in which the repeated people count more than once. The difference here is small; Join Queries shows the same mechanism move a mean blood pressure by more than a millimeter. When the question is whether a match exists, a semi-join states it exactly.
Rewriting a subquery as a join is sometimes recommended for speed, on the grounds that a join is optimized as a whole. The steps are to move the subquery's table into the outer FROM clause, turn the link between the queries into a join condition, and add DISTINCT if the join can repeat outer rows. The last step is the one that is easy to forget and, as the table shows, it is not enough when the query computes more than counts. Current planners also do much of this work themselves. SQLite's plan for the IN query evaluates the subquery once into a list (and in SQLite 3.49 adds a Bloom filter to speed up lookups), and its documentation describes how it flattens subqueries in the FROM clause into the outer query, under a long list of conditions, because "performance of complex queries and/or queries involving views tends to suffer if query flattening is more conservative" (SQLite, n.d.-c). The clearer formulation is usually the better starting point, with EXPLAIN QUERY PLAN consulted if it turns out slow.
NOT IN and NOT EXISTS
The negations are where the forms part company. The question: how many of the 666 drugs in the database does no child take? The 1,082 prescriptions reported for people under 18 include 23 recorded only as an unknown, refused or don't-know code, whose drug_id is NULL.
SELECT COUNT(*) FROM drug
WHERE drug_id NOT IN (SELECT p.drug_id
FROM prescription AS p JOIN person AS pe USING (seqn)
WHERE pe.age < 18); -- 0
SELECT COUNT(*) FROM drug AS d
WHERE NOT EXISTS (SELECT 1
FROM prescription AS p JOIN person AS pe USING (seqn)
WHERE pe.age < 18 AND p.drug_id = d.drug_id); -- 475
The NOT EXISTS query finds 475 drugs that no child takes, which with the 191 that some child takes accounts for all 666. The NOT IN query finds none. For a drug that no child takes, drug_id NOT IN (list) means drug_id <> x for every x in the list, and one of those x is NULL, so the condition is unknown rather than true for every drug, and every drug is dropped. The SQLite documentation's table of IN results gives exactly this: when the right operand contains NULL and the left value is not found, both IN and NOT IN are NULL (SQLite, n.d.-a). Special Operators and Clauses shows the same effect with a literal list.
The query does not look dangerous, the NULLs are not visible in it, and the answer, zero, is plausible enough to pass a quick check. Adding AND p.drug_id IS NOT NULL to the subquery repairs it and gives 475, but the safer habit is to use NOT EXISTS for anti-joins, because it tests for a matching row and a NULL never matches. A left join with an IS NULL test, shown in Join Queries, is equally safe.
Correlated subqueries
A subquery that refers to a column of the outer query is correlated. Its result depends on the outer row, so logically it is evaluated again for each row; the SQLite documentation says that "A correlated subquery is reevaluated each time its result is required. An uncorrelated subquery is evaluated only once and the result reused as necessary" (SQLite, n.d.-a). Comparing each adult's blood pressure with the mean for adults of the same sex and decade of age:
SELECT COUNT(*) AS above_group_mean
FROM adult_bp AS a
WHERE a.sbp > (SELECT AVG(b.sbp)
FROM adult_bp AS b
WHERE b.sex = a.sex AND b.age / 10 = a.age / 10); -- 2,368
The aliases are essential: a is the outer adult and b ranges over the adults in the subquery, and without them sex and age would refer to the inner table only. Read literally, the query computes a group mean 5,247 times, once per adult, although there are only 16 groups. A database may cache or rewrite such work, but it is not obliged to; SQLite's plan here labels the subquery CORRELATED SCALAR SUBQUERY and re-evaluates it.
Two rewrites compute each group mean once. A window function places the group mean on every row (Aggregate Functions):
SELECT COUNT(*) FROM (
SELECT sbp, AVG(sbp) OVER (PARTITION BY sex, age / 10) AS m FROM adult_bp)
WHERE sbp > m; -- 2,368
and a join to a grouped table does the same in standard SQL that predates window functions:
SELECT COUNT(*)
FROM adult_bp AS a
JOIN (SELECT sex, age / 10 AS decade, AVG(sbp) AS m
FROM adult_bp GROUP BY sex, decade) AS g
ON g.sex = a.sex AND g.decade = a.age / 10
WHERE a.sbp > g.m; -- 2,368
All three return 2,368. The correlated form reads most like the question and is fine on small tables; the other two scale better. A correlated scalar subquery in the SELECT list is also a convenient way to attach a count to each row, such as (SELECT COUNT(*) FROM prescription AS p WHERE p.seqn = pe.seqn) AS medicines, which gives 0 for people with no prescriptions where an inner join would drop them.
Subqueries in FROM: derived tables
A subquery in the FROM clause produces a table for the outer query to read, called a derived table. It is the standard way to aggregate in two steps, first to one row per person and then across people:
SELECT sex, COUNT(*) AS adults, ROUND(AVG(sbp), 2) AS mean_sbp
FROM (SELECT p.seqn, p.sex, AVG(r.sbp) AS sbp
FROM person AS p JOIN bp_reading AS r USING (seqn)
WHERE p.age >= 18 AND r.reading <= 3
GROUP BY p.seqn, p.sex) AS per_person
GROUP BY sex;
This gives 125.37 mm Hg for 2,700 women and 127.41 for 2,547 men, the person-weighted means of Aggregate Functions, without a stored view. The SQL standard requires the derived table to have a name (AS per_person), and so do MySQL and SQL Server (MySQL, n.d.; Microsoft, n.d.); SQLite does not insist, and PostgreSQL, whose documentation states the standard's requirement, allows the name to be omitted from version 16 (PostgreSQL Global Development Group, n.d.-b, n.d.-c). Naming it costs nothing and keeps the query portable.
Common table expressions
Nested derived tables become hard to read from the inside out. A common table expression (CTE) names a subquery before the main query, with WITH, and the main query then uses the name like a table. The SQLite documentation describes ordinary CTEs as acting "like temporary views that exist only for the duration of a single SQL statement" (SQLite, n.d.-b). Several can be defined in one WITH, and later ones can use earlier ones:
WITH per_person AS (
SELECT seqn, AVG(sbp) AS sbp
FROM bp_reading
WHERE reading <= 3
GROUP BY seqn
),
statin_users AS (
SELECT DISTINCT p.seqn
FROM prescription AS p JOIN drug AS d USING (drug_id)
WHERE d.name LIKE '%STATIN' AND d.name <> 'NYSTATIN'
)
SELECT CASE WHEN s.seqn IS NULL THEN 'no statin' ELSE 'statin' END AS group_,
COUNT(*) AS adults,
ROUND(AVG(b.sbp), 2) AS mean_sbp,
ROUND(AVG(l.chol), 2) AS mean_chol
FROM person AS pe
JOIN per_person AS b USING (seqn)
LEFT JOIN lab AS l USING (seqn)
LEFT JOIN statin_users AS s USING (seqn)
WHERE pe.age >= 40
GROUP BY group_;
| group_ | adults | mean_sbp | mean_chol |
|---|---|---|---|
| no statin | 2,411 | 131.19 | 202.02 |
| statin | 1,091 | 134.12 | 169.14 |
Among adults aged 40 and over with a blood pressure reading, those taking a statin have a mean total cholesterol 33 mg/dL lower and a systolic pressure 3 mm Hg higher than those not taking one. The query reads top to bottom: define the people's blood pressure, define who takes a statin, then compare. The comparison itself illustrates why grouped differences need care (Exploring Data with Groups and Pivot Tables): statin users are older, 66.9 years on average against 58.0, and are taking the drug because their cholesterol was high, so neither difference is the effect of the drug. Confounding and Causal Diagrams treats this kind of comparison formally.
CTEs are mainly a tool for readability. Whether the database evaluates a CTE once and stores the result or merges it into the main query depends on the system and version; SQLite decides for itself and accepts hints (AS MATERIALIZED, AS NOT MATERIALIZED) to override it (SQLite, n.d.-b).
Recursive common table expressions
One capability is new rather than a convenience. A CTE declared with WITH RECURSIVE may refer to itself, which lets a query generate rows that are not stored anywhere and walk trees and graphs. The SQLite documentation calls this "a capability that is not otherwise available in the SQL language" (SQLite, n.d.-b). The simplest example counts:
WITH RECURSIVE n(i) AS (
SELECT 1 -- initial row
UNION ALL
SELECT i + 1 FROM n WHERE i < 5 -- recursive step
)
SELECT i, i * i AS square FROM n;
It returns the integers 1 to 5 and their squares. The body is a compound select: an initial select that produces the starting rows, then UNION ALL, then a recursive select that refers to the CTE once. SQLite evaluates it with a queue: it runs the initial select, then repeatedly takes one row from the queue, runs the recursive select as if that row were the whole table, and adds the results to the queue, until the queue is empty (SQLite, n.d.-b). The WHERE i < 5 is what empties the queue; without a terminating condition the recursion runs until something else stops it.
A practical use is filling gaps. A histogram of adult BMI in bins five units wide, computed with GROUP BY, has a row only for bins that contain someone:
SELECT CAST(bmi / 5 AS INTEGER) * 5 AS lower, COUNT(*) AS adults
FROM exam JOIN person USING (seqn)
WHERE age >= 20 AND bmi IS NOT NULL
GROUP BY lower;
The result jumps from the bin starting at 70 to the one starting at 80: no adult has a BMI from 75 to 80, so that bin is not in the output, and a chart drawn from it would silently close the gap. Generating the bins first and joining the data to them puts the empty bin back:
WITH RECURSIVE bins(lower) AS (
SELECT 10
UNION ALL
SELECT lower + 5 FROM bins WHERE lower < 85
)
SELECT b.lower, b.lower + 5 AS upper, COUNT(e.seqn) AS adults
FROM bins AS b
LEFT JOIN (SELECT e.seqn, e.bmi
FROM exam AS e JOIN person AS p USING (seqn)
WHERE p.age >= 20) AS e
ON e.bmi >= b.lower AND e.bmi < b.lower + 5
GROUP BY b.lower;
| lower | upper | adults |
|---|---|---|
| 15 | 20 | 233 |
| 20 | 25 | 1,101 |
| 25 | 30 | 1,667 |
| 30 | 35 | 1,132 |
| 35 | 40 | 569 |
| 40 | 45 | 277 |
| 45 | 50 | 101 |
| 50 | 55 | 50 |
| 55 | 60 | 22 |
| 60 | 65 | 12 |
| 65 | 70 | 5 |
| 70 | 75 | 1 |
| 75 | 80 | 0 |
| 80 | 85 | 1 |
| 85 | 90 | 1 |
(and 3 adults in the bin from 10 to 15). COUNT(e.seqn) rather than COUNT(*) is what makes the empty bin 0 instead of 1: the left join produces one row for the empty bin with NULLs on the data side, and COUNT of a column skips them. The same pattern, a generated series left-joined to the data, fills missing dates in a time series and missing categories in a report. PostgreSQL has a built-in generate_series for the purpose; in SQLite and in portable SQL the recursive CTE does the job.
The other classic use is hierarchies: an employee table whose rows point to their managers, a parts list in which parts contain parts. Codd's own example of a relation with two columns drawn from the same domain was such a table, component, in which one part is a component of another, "a relation which plays a critical role in the parts explosion problem" (Codd, 1970). A recursive CTE starts from one part and repeatedly joins the table to the rows found so far, listing every component at every level. The SQLite documentation works through such queries on an organization chart and a family tree (SQLite, n.d.-b).
Worked problems
The three problems state exactly when the forms this article treats as interchangeable are interchangeable, and what a recursive query computes. The review-pass block of sql-subqueries.py checks each on SQLite 3.49.1.
Problem 1 (when NOT IN and NOT EXISTS agree). The article found that NOT IN returned 0 drugs where NOT EXISTS returned 475. Characterize exactly when the two forms of an anti-join keep the same rows.
Approach. Write the subquery's values as a list $S$ and the outer value as $x$. Work out the truth value of each form from the three-valued logic of Simple SQL Queries: x NOT IN S means $x \ne s$ for every $s$ in $S$, joined by AND. NOT EXISTS with the correlation s = x is true when no element satisfies $s = x$, that is, when the comparison is true for none of them.
Cases. If $S$ is empty, the conjunction has no terms and is true, so NOT IN keeps every row, even one with $x$ NULL, and NOT EXISTS keeps every row too. Otherwise:
- If $x$ equals some element, one term is false, so
NOT INis false, andNOT EXISTSfinds the match and is false. They agree. - If $x$ is not NULL, equals no element, and $S$ has no NULL, every term is true, and both forms are true. They agree.
- If $x$ is not NULL, equals no element, and $S$ contains a NULL, the term $x \ne \text{NULL}$ is unknown and no term is false, so
NOT INis unknown and drops the row, whileNOT EXISTSfinds no element equal to $x$ and keeps it. - If $x$ is NULL, every term is unknown, so
NOT INdrops the row, whileNOT EXISTSfinds no element with $s = x$ true and keeps it.
The two forms therefore disagree on a row, for a nonempty list, exactly when the outer value is NULL (fourth case) or when it is not NULL, is not found and the list contains a NULL (third case). So they keep the same rows exactly when the list is empty, or the outer value is never NULL and either the list contains no NULL or every outer value is found in it. In practice they agree when the outer column and the subquery's column are both declared NOT NULL.
Checks. The drug example is the third case: the children's prescriptions include 23 with a NULL drug_id, and NOT IN keeps no drug; adding p.drug_id IS NOT NULL gives the 475 of NOT EXISTS. The fourth case appears when the roles are reversed, with a list that contains no NULL at all. Counting prescriptions that are not for a statin, NOT IN the list of statin identifiers gives 13,083 and NOT EXISTS gives 13,217; the difference is the 134 prescriptions whose own drug_id is NULL, which are certainly not statin prescriptions but which NOT IN cannot say so about. The empty case holds too: NOT IN an empty subquery keeps all 14,434 prescriptions, the 134 with NULL included, and SQLite evaluates NULL NOT IN (SELECT 1 WHERE 0) as true, as its table of IN results states (SQLite, n.d.-a).
Problem 2 (when the rewrites of a correlated subquery are not equivalent). The article rewrote a correlated subquery comparing each adult with the mean of their sex and decade as a window function and as a join to a grouped table, and all three returned 2,368. Find a grouping for which they differ, and explain the difference.
Approach. The three forms compute the same group mean for each row only if they form the same groups. The correlated subquery and the join form a group with the condition b.key = a.key; the window function forms groups with PARTITION BY key. These treat NULL differently: equality with NULL is never true, but PARTITION BY, like GROUP BY, puts all NULL keys in one group. Sex and decade are never NULL, so the article's example could not show the difference. Education can: it is NULL for the adults aged 18 and 19, who were not asked.
Results. Comparing each adult's systolic pressure with the mean for their education level, the window function counts 2,284 adults above their group's mean, and the correlated subquery and the grouped join each count 2,159. The 251 adults with NULL education account for the difference. For each of them the correlated subquery averages over the rows with b.education = NULL, which is no row, so its mean is NULL and the comparison unknown; the join to the grouped table finds no group row to match. The window function puts them in a group of their own, and 125 of them are above that group's mean: $2{,}159 + 125 = 2{,}284$. Writing the correlation with SQLite's IS, b.education IS a.education, which treats two NULLs as equal, makes the correlated subquery agree with the window function. Which answer is right depends on whether the people without an education value should be compared with each other; the point is that the rewrite changed the question without any warning.
Problem 3 (what a recursive query computes, and why it stops). Prove that the counting query returns exactly the integers 1 to 5, and explain why a recursion over a cycle stops with UNION and not with UNION ALL.
Proof for the counting query. SQLite's evaluation, described in the article, keeps a queue: the initial select puts the row 1 in it; then, while the queue is not empty, one row is removed, emitted, and the recursive select is run on that row alone, its results added to the queue (SQLite, n.d.-b). By induction, after the row $i$ is removed, the recursive select on it produces $i + 1$ if $i < 5$ and nothing otherwise. So the rows emitted are 1, 2, 3, 4, 5 in turn, and when 5 is removed it adds nothing, the queue is empty and the evaluation stops. The rows are the least set containing 1 and closed under the step, which is the meaning of the recursive definition.
Cycles. A recursive step SELECT i % 5 + 1 FROM n maps 1 to 2, ..., 5 back to 1, a cycle. With UNION ALL every produced row joins the queue, so the queue never empties, and only a LIMIT stops it: LIMIT 12 returns 1 to 5, 1 to 5, 1, 2. With UNION, SQLite adds a row to the queue only if no identical row has been added before (SQLite, n.d.-b). The rows are drawn from a finite set, here five values, so at most five rows are ever added, and the evaluation stops after emitting 1 to 5 once. This is why recursion over graphs that may contain cycles, such as a parts list with an error that makes a part contain itself, should use UNION or carry a depth counter with a limit. The bin generator of the histogram, which steps from 10 by 5 while below 85, produces 16 rows and stops for the same reason as the counting query.
Open questions
- How much does decorrelation save? Timing the correlated, windowed and grouped forms of the group-mean comparison over 30 runs, on
adult_bpreplicated 1 to 100 times, withEXPLAIN QUERY PLANfor each, would show whether SQLite rewrites the correlated form and how the cost grows with the table. - Do PostgreSQL and SQLite plan
INandEXISTSthe same way? Comparing the plans and timings of the statin queries in both engines, pinned to stated versions, would test the article's claim that modern planners often turn one form into the other. - Can the NULL hazard of
NOT INbe found automatically? A check that flags everyNOT IN (subquery)whose subquery column is nullable, run over the SQL in this repository's experiment scripts, would show how often the hazard arises in practice and whether a declaredNOT NULLwould remove it.
Where it leads
A subquery is a query used where a value, a list or a table is expected: scalar subqueries return one value (in SQLite, silently, the first row), IN and EXISTS are semi-joins, NOT EXISTS is the safe anti-join, and common table expressions name subqueries and, recursively, generate rows. Queries in Python moves the queries of this topic into programs: the interface that database drivers share, parameters that keep data out of the SQL text, reading results into pandas, and transactions.
In Python
import sqlite3
import pandas as pd
con = sqlite3.connect("nhanes.db")
drugs_no_child_takes = pd.read_sql("""
SELECT d.name FROM drug AS d
WHERE NOT EXISTS (SELECT 1 FROM prescription AS p JOIN person AS pe USING (seqn)
WHERE pe.age < 18 AND p.drug_id = d.drug_id)
ORDER BY d.name""", con)
len(drugs_no_child_takes) # 475
# the anti-join in pandas
child_drugs = pd.read_sql("""SELECT p.drug_id FROM prescription AS p
JOIN person AS pe USING (seqn) WHERE pe.age < 18""", con)
drug = pd.read_sql("SELECT * FROM drug", con)
(~drug.drug_id.isin(child_drugs.drug_id)).sum() # 475
isin in pandas does not use three-valued logic: a missing value in the list can match only a missing value in the column, and drug_id has none, so the negated isin behaves like NOT EXISTS, not like SQL's NOT IN. The numbers in this article are computed by tools/experiments/data-science/sql-subqueries.py in the site's repository.
References
- Codd, E. F. (1970). A relational model of data for large shared data banks. Communications of the ACM, 13(6), 377–387. https://doi.org/10.1145/362384.362685 record · 4 pages
- Microsoft (n.d.). FROM clause plus JOIN, APPLY, PIVOT (Transact-SQL). https://learn.microsoft.com/en-us/sql/t-sql/queries/from-transact-sql record
- MySQL (n.d.). Derived tables. MySQL 8.4 Reference Manual. https://dev.mysql.com/doc/refman/8.4/en/derived-tables.html record
- PostgreSQL Global Development Group (n.d.-a). Value expressions. PostgreSQL documentation. https://www.postgresql.org/docs/current/sql-expressions.html record
- PostgreSQL Global Development Group (n.d.-b). SELECT. PostgreSQL documentation. https://www.postgresql.org/docs/current/sql-select.html record · 4 pages
- PostgreSQL Global Development Group (n.d.-c). PostgreSQL 16 release notes. https://www.postgresql.org/docs/release/16.0/ record
- SQLite (n.d.-a). SQL language expressions. https://sqlite.org/lang_expr.html record · 4 pages
- SQLite (n.d.-b). The WITH clause. https://sqlite.org/lang_with.html record
- SQLite (n.d.-c). The SQLite query optimizer overview. https://sqlite.org/optoverview.html record
Reviewed: verified, 23 Nov 2026 · citations checked, 23 Nov 2026 · editorial review, 23 Nov 2026 · 4 revisions