Lesson 18 of 22 · PostgreSQL

CTEs (WITH clause)

Write readable queries with PostgreSQL CTEs (the WITH clause).

CTEs make complex queries readable by naming intermediate results.

Syntax

WITH cte_name AS (
    SELECT ...
)
SELECT * FROM cte_name;

Your challenge

Using a CTE, return the names (only the name column) of users whose name is longer than 15 characters.

Solve it in your browser

Free, no sign-up. The PostgreSQL database runs in your browser; your answer is checked instantly, with hints if you need them.