clause
WITH
Names a query expression for use within a statement. Do not assume it always creates a stored intermediate table. Example target: PostgreSQL 17 and SQLite (local fixture tested).
Formal Syntax & Structure
sql syntaxsql
WITH name AS (query) SELECT ...Working Example
Example Snippetsql
WITH expensive AS (SELECT id FROM orders WHERE amount > 100) SELECT id FROM expensive ORDER BY id;