SQLSyntax
Common Table Expression
Code example
WITH recent AS (
SELECT * FROM orders WHERE created_at > now() - interval '7 days'
)
SELECT * FROM recent;Names a temporary result set with WITH.
In SQL, common table expression: names a temporary result set with WITH — WITH recent AS ( SELECT * FROM orders WHERE created_at > now() - interval '7 days' ) SELECT * FROM recent;
WITH recent AS (
SELECT * FROM orders WHERE created_at > now() - interval '7 days'
)
SELECT * FROM recent;WITH recent AS (
SELECT * FROM orders WHERE created_at > now() - interval '7 days'
)
SELECT * FROM recent;Names a temporary result set with WITH.
Use WITH recent AS ( SELECT * FROM orders WHERE created_at > now() - interval '7 days' ) SELECT * FROM recent;.
Use this pattern: WITH recent AS ( SELECT * FROM orders WHERE created_at > now() - interval '7 days' ) SELECT * FROM recent;
Yes. Use Copy code and adapt the example to your program.
No. The language syntax is the same across operating systems.