Build your Final Model
Purpose
Key Components
Creating a Final Model File
-- models/customer_orders.sql
SELECT
c.customer_id,
c.first_name,
c.last_name,
COUNT(o.order_id) as number_of_orders,
SUM(o.amount) as total_order_value
FROM {{ ref('stg_customers') }} c -- Using ref() to reference another model
LEFT JOIN {{ ref('stg_orders') }} o ON c.customer_id = o.customer_id
GROUP BY 1, 2, 3Understanding the ref() Function
Running Your Final Model
Best Practices
Last updated
Was this helpful?