2024-10-16 12:15:14 +00:00
|
|
|
{% set id_deal_pipelines_excluded = "('15380854')" %}
|
|
|
|
|
|
|
|
|
|
with
|
|
|
|
|
stg_hubspot__deals as (select * from {{ ref("stg_hubspot__deals") }}),
|
|
|
|
|
stg_hubspot__deal_pipeline_stages as (
|
|
|
|
|
select * from {{ ref("stg_hubspot__deal_pipeline_stages") }}
|
|
|
|
|
),
|
|
|
|
|
stg_hubspot__deal_pipelines as (
|
|
|
|
|
select * from {{ ref("stg_hubspot__deal_pipelines") }}
|
|
|
|
|
)
|
|
|
|
|
select
|
|
|
|
|
d.id_deal,
|
|
|
|
|
d.deal_name,
|
|
|
|
|
d.contract_signed_date_utc,
|
|
|
|
|
d.onboarding_date_utc,
|
|
|
|
|
d.live_date_utc,
|
|
|
|
|
d.cancellation_date_utc,
|
|
|
|
|
d.account_manager,
|
|
|
|
|
dp.deal_pipeline_name as deal_pipeline,
|
|
|
|
|
dps.stage_name as deal_hubspot_stage,
|
|
|
|
|
d.cancellation_category,
|
|
|
|
|
d.cancellation_details,
|
2024-12-17 09:02:11 +00:00
|
|
|
d.amount_of_properties,
|
2025-03-07 10:17:11 +01:00
|
|
|
d.last_contacted_date_utc,
|
|
|
|
|
d.amount_times_contacted,
|
2024-10-16 12:15:14 +00:00
|
|
|
d.created_at_utc,
|
|
|
|
|
d.created_date_utc,
|
|
|
|
|
d.updated_at_utc,
|
|
|
|
|
d.updated_date_utc
|
|
|
|
|
from stg_hubspot__deals d
|
|
|
|
|
left join stg_hubspot__deal_pipeline_stages dps on d.id_deal_stage = dps.id_stage
|
|
|
|
|
left join stg_hubspot__deal_pipelines dp on dps.id_deal_pipeline = dp.id_deal_pipeline
|
|
|
|
|
-- Exclude Guardhog pipelines
|
|
|
|
|
where dps.id_deal_pipeline not in {{ id_deal_pipelines_excluded }}
|