Skip to content

WITH

WITH sample AS (
SELECT 'Hello, SQL!' AS Column1
)
SELECT * FROM sample;
Column1
-----------
Hello, SQL!
(1 row)

In the provided example, the SQL statement consists of a WITH clause, often referred to as a “Common Table Expression” (CTE). The WITH clause creates a temporary table ‘sample’ which contains a single data row with the value ‘Hello, SQL!’. The SELECT statement that follows fetches all the data (in this case, a single data row) from this temporary table.