A common table expression (CTE) is a named temporary result set that you can reference within a SELECT, INSERT, UPDATE, DELETE, or CREATE VIEW statement. It can be used to simplify complex queries by breaking them up into smaller, more manageable pieces and can also improve the readability and maintainability of the query.  For example, the following query uses a CTE to return the names and order totals of customers who have placed an order with a total greater than $100:  WITH HighValueOrders AS (
SELECT CustomerID, SUM(Total) AS OrderTotal
FROM Orders
GROUP BY CustomerID
HAVING SUM(Total) > 100
)
SELECT c.CustomerName, hvo.OrderTotal
FROM Customers c
JOIN HighValueOrders hvo ON hvo.CustomerID = c.CustomerID;