commit wip

This commit is contained in:
Joaquin Ossa 2025-03-06 11:02:46 +01:00
parent 9f580867c0
commit 089a1c37bd

View file

@ -0,0 +1,25 @@
with
stg_hubspot__deals as (select * from {{ ref("stg_hubspot__deals") }}),
int_monthly_aggregated_metrics_history_by_deal_by_time_window as (
select *
from {{ ref("int_monthly_aggregated_metrics_history_by_deal_by_time_window") }}
),
int_core__user_host as (select * from {{ ref("int_core__user_host") }}),
int_core__accommodation as (select * from {{ ref("int_core__accommodation") }})
select
d.id_deal,
m.main_deal_name,
m.client_type,
m.has_active_pms,
m.active_pms_list,
d.cancellation_date_utc,
date_trunc('month', d.cancellation_date_utc) as churn_month,
from stg_hubspot__deals d
left join
int_monthly_aggregated_metrics_history_by_deal_by_time_window m
on d.id_deal = m.id_deal
and date_trunc('month', d.cancellation_date_utc) = date_trunc('month', m.date)
left join int_core__user_host uh on d.id_deal = uh.id_deal
left join int_core__accommodation a on uh.id_user_host = a.id_user_host
where d.cancellation_date_utc is not null