Problem Statement
What does a Common Table Expression (CTE) primarily provide?
Explanation
A CTE created with WITH gives a readable name to an intermediate query and exists only for that statement. Many engines inline it like a subquery.
CTEs are about clarity and stepwise logic. Performance depends on the optimizer and data shape, not the syntax alone.
Code Solution
SolutionRead Only
WITH recent AS ( SELECT * FROM orders WHERE created_at >= CURRENT_DATE - INTERVAL '30 days' ) SELECT * FROM recent WHERE status = 'PAID';
