Common table expression (CTE)
Also called: CTE, WITH clause
A named step in an SQL query, written with WITH, that makes complex queries readable.
Definition
A CTE exists only while the query runs. Testers use them to build checks step by step, for example "paid per order" first, then compare it with each order's total.
In practice
WITH paid AS (SELECT order_id, SUM(amount) AS paid FROM payments GROUP BY order_id) SELECT … FROM orders o LEFT JOIN paid …
Learn it in context
Lessons that use this term.