Good job! There is also an alternative CTE syntax that looks like this:
WITH order_total_prices (order_id, total_price) AS (
SUM(unit_price * quantity)
FROM orders o
JOIN order_items oi
ON o.order_id = oi.order_id
GROUP BY o.order_id
AVG(total_price) AS avg_total_price
This time, we provided the column names right after the CTE's name, inside a pair of parentheses (
WITH order_total_prices (order_id, total_price) AS ...). This way, we didn't have to use the
AS keyword to name the columns inside the CTE.
This syntax is completely optional. It's up to you whether you want to use it and it depends on your personal preferences.