A common table expression (CTE) is a named subquery written at the top of a query with WITH. Instead of nesting brackets, you write steps in reading order:
WITH customer_totals AS (
SELECT customer_id, SUM(total) AS spent
FROM orders
GROUP BY customer_id
)
SELECT customer_id, spent
FROM customer_totals
WHERE spent > 250;
The CTE works like a temporary table that exists only for this query. You can define several, separated by commas (WITH a AS (...), b AS (...)), and a later one can read from an earlier one.
CTEs don't make a query faster; they make it easier to read, test and change. A good habit is to build a query one step at a time: write the first CTE, select from it to check the rows, then add the next. Analysts use them constantly, and in an interview they make your thinking easy to follow.