7.8. WITH Queries (Common Table Expressions)
WITH provides a way to write auxiliary statements for use in a larger query. These statements, which are often referred to as Common Table Expressions or CTEs, can be thought of as defining temporary tables that exist just for one query.
https://www.postgresql.org/docs/12/queries-with.html