Key things to know

Worked example

Below is the code for an example dbt model called current_pipeline. See the toggle below for its column-level lineage. We’ve hidden it in case you want to try to work through the answer yourself first!

title="models/marts/sales/current_pipeline.sql"
select 
  r.pipeline_id,
  r.stage_id,
  s.order_nr as stage_order,
  coalesce(r.funnel_size,0) as funnel_size
from {{ ref('base_pipedrive__stage') }} s
left join {{ ref('ranked_deals') }} r on r.stage_id = s.id
where r.pipeline_id = 1
order by s.order_nr desc