WITH — defines a Common Table Expression (CTE)
WITH cte_name AS (
-- Query defining the CTE
SELECT column1, column2, ...
-- Main query referencing the CTE defined earlier
WITH clause is used to define and name a CTE.
The query that defines the CTE is specified after the
This query can include SELECT statements, joins, filtering conditions, and other SQL operations.
The result of this query is a table and it forms the temporary result set of the CTE.
The CTE can be referenced in the main query that can be a